私は携帯電話でこれを書いているので、現時点では完全なコード例は問題外ですが、助けが必要です.
私は、圧縮されたインファイルから一連の .csv ファイルを解析し、各ファイルから特定の列を取り出し、選択した列で新しい .csv を生成し、新しいデータフレームを圧縮されたアウトファイルにエクスポートすることに取り組んでいます。
私は一連のループを通してこれを行っていますが、解析プロセスで 78% を超える成功を収めることはできず、圧縮プロセスと組み合わせた解析では 73% を超えることができません。
途中のどこかで zipfile.ZipFile が壊れているか、pandas.to_csv が壊れている...理由がわかりません。私は2週間それを理解しようとしてきましたが、ついに助けを求めるために壊れています.
今のところ簡単なコード スニペット:
エクスポート機能:
def export(new_filename):
os.chdir([import_file location])
try:
with zipfile.ZipFile(outfile_name,'a',zipfile=ZIP_DEFLATED, allowZip64=true) as outfile:
try:
outfile.write(new_filename)
#random errors at runtime saying the writing handle is still open... Not sure why.
except:
#print statement to alert of failure at this step. I have tried NameError
#and ValueError exceptions, but they don't help.
except:
#another statement to alert failure
パンダ機能:
def infile_parser(filename, new_filename):
#excluding code beyond making the dataframe and file generation
df = pd.dataframe(data,columns=useful_columns)
df.to_csv(new_filename,index=false)
前もって感謝します。リクエストがあれば、コンテキストを追加できます。