這是我的 OCR 代碼的一部分。這部分在掃描的 PDF 中查找特殊單詞并將其列印出來。我有 10 個這樣的查詢,并且都列印出我正在尋找的單詞。現在我想將找到的單詞保存在 CSV 中,但我不知道該怎么做。有人能幫助我嗎?
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)
′′′
uj5u.com熱心網友回復:
是基礎知識。
在開始時創建空串列,將單詞添加到串列中,然后使用csv或寫入所有串列pandas
我不知道您要保存哪些變數
# - at start -
all_words = []
# ... your code ...
all_words.append( word )
# - at the end -
df = pd.DataFrame({"words": all_words})
df.to_csv("words.csv")
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/438118.html
下一篇:如何剝離自定義的缺失值熊貓資料框
