我是 python 新手,并试图从包含数百万行的文件中解析数据。试图去老学校使用 excel 解析它,但它失败了。如何有效地解析信息并将其导出为 excel 文件,以便其他人阅读?
我尝试使用其他人提供的此代码,但到目前为止没有运气
import re
import pandas as pd
def clean_data(filename):
with open(filename, "r") as inputfile:
for row in inputfile:
if re.match("\[", row) is None:
yield row
with open(clean_file, 'w') as outputfile:
for row in clean_data(filename):
outputfile.write(row)
NameError: name 'clean_file' is not defined