Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

OCR: Saving Words in a CSV-file

this is a part of my OCR code. This part looks for a special word in a scanned PDF and prints this out. I have like 10 Queries like this and all print me the word I am looking for. Now I want to get the found words saved in a CSV, but I don’t know how to do that. Can Someone help me, please?

QueryNumberZW = (ErgebnisPandas.query('Word=="ZW" & Wordindex<40 & Page==1').index.tolist())
print(QueryNumberZW)

if QueryNumberZW: 
    ResultNumberZW = (ErgebnisPandas['Wort'].iloc[QueryNumberZW[0]:QueryNumberZW[0]+3])
    ResultNumberZW = ' '.join(ResultNumberZW)
 
    print(ResultNumberZW)

´´´

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

It is basic knowledge.

Create empty list at start, append() words to list, and later write all list using csv or pandas

I have no idea which variables you want to save

# - at start -
all_words = [] 

# ... your code ...
all_words.append( word )

# - at the end -
df = pd.DataFrame({"words": all_words})
df.to_csv("words.csv")
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading