41 lines
851 B
Go
41 lines
851 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"regexp"
|
|
"strings"
|
|
|
|
"t0xa/pdf_to_txt/internal/parser"
|
|
)
|
|
|
|
type CheckEntry struct {
|
|
Product string
|
|
Price string
|
|
}
|
|
|
|
func main() {
|
|
// TODO: Redo format of file passing to function
|
|
text := parser.ParseX5Check("./internal/parser/testfiles/test3.pdf")
|
|
|
|
split := strings.Split(text, "\n")
|
|
stringsToFilter := "https://mail|Gmail - Электронный чек|Сумма|НДС"
|
|
re := regexp.MustCompile(stringsToFilter)
|
|
filtered := []string{}
|
|
for _, element := range split {
|
|
if re.MatchString(element) {
|
|
continue
|
|
}
|
|
if len(element) < 1 {
|
|
continue
|
|
}
|
|
filtered = append(filtered, element)
|
|
|
|
}
|
|
for index, element := range filtered {
|
|
if element == "Цена*Кол" {
|
|
fmt.Println("Товар: ", filtered[index-1])
|
|
fmt.Println("Цена: ", filtered[index+1])
|
|
fmt.Println("------")
|
|
}
|
|
}
|
|
}
|