I filter a substring from a string.
But now I want to print the number after the substring. in this case it is index number 475. And then I want to print that number.
So this is whole string:
Crownless 14kg 10 Sweet CR Klasse I € 7,00 € 3.962,00\n706 Appels Royal Gala 13kg 60/65 Generica PL Klasse I € 4,68 € 3.304,08\n598 Peen Waspeen 14x1lkg 200-400 Generica BE Klasse I € 6,30 3.767,40\nOrder number : 76462 Loading date : 18-11-21 Incoterm: : FOT\nYour ref.
And then I have this substring:
Appels Royal Gala 13kg 60/65 Generica PL Klasse I
and then I want to print the number: 3.304,08.
So this number is on index 475.
But how to print now this number?
This is my code fragment:
pdfFile = wi(
filename="C:PDF.pdf", resolution=300)
image = pdfile.convert('jpeg')
imageBlobs = []
for img in image.sequence:
imgPage = wi(image=img)
imageBlobs.append(imgPage.make_blob('jpeg'))
text_factuur_verdi = []
royal_gala = 'Royal Gala 13kg 60/65 Generica PL Klasse I'
crownless = 'Crownless 14kg 10 Sweet CR Klasse I'
waspeen = 'Waspeen 14x1lkg 200-400 Generica BE Klasse I'
for imgBlob in imageBlobs:
image = Image.open(io.BytesIO(imgBlob))
text = pytesseract.image_to_string(image, lang='eng')
text_factuur_verdi.append(text)
allSubstring = re.search(appels_royal_gala, text)
#indexEndAllsubstring = ' '.join(allSubstring)
print(allSubstring.end() + 11)
Or maybe there is a better way to do this?
in any case it is the second number after the substring:
Royal Gala 13kg 60/65 Generica PL Klasse I
€ 4,68 € 3.304,08
Thank you