[英]Python) to_csv: my csv file data is separated and pushed back
I'm saving my pd.DataFrame with """df.to_csv('df.csv', encoding='utf-8-sig)"""我用 """df.to_csv('df.csv', encoding='utf-8-sig)""" 保存我的 pd.DataFrame
my csv file have a problem...我的csv文件有问题...
please see rows, where have content2-1, content2-2, and content2-3 in this pic.请查看此图片中包含 content2-1、content2-2 和 content2-3 的行。
Before saving(to_csv), there was no problem.在保存(to_csv)之前,没有问题。 All the data had right columns, 'content2' was not separated.
所有数据都有正确的列,'content2'没有分开。 but after df -> csv...
但在 df -> csv 之后...
'content2' is all separated, and the others of 'id2' are allocated to the wrong columns. 'content2' 全部分开,'id2' 的其他部分分配到错误的列。 "2018-04-21" have to be in column D, 0 with E,F,G, and url must be in column I.
“2018-04-21”必须在 D 列,0 和 E、F、G,并且 url 必须在 I 列。
why this happen?为什么会这样? because of large csv file?(774,740KB), because of language?(Korean), or csv cannot recognize enter key?(All data with problems such as content2 were separated based on the enter key.)
因为csv文件大?(774,740KB),因为语言?(韩文),还是csv无法识别回车键?(所有有问题的数据,如content2,都是根据回车键分开的。)
how can I resolve this?我该如何解决这个问题? I have no idea
我不知道
Unfortunately I never figured out the reason for this.. I assumed it was something to do with the size of the data i was working with and excel not liking it.不幸的是,我从来没有弄清楚原因。我认为这与我正在使用的数据的大小有关,而 excel 不喜欢它。
What worked for me though was using .to_excel() instead of to_csv().对我有用的是使用 .to_excel() 而不是 to_csv()。 I know, far from a perfect answer, but thought id put it here incase it is enough for your case
我知道,远不是一个完美的答案,但我想把它放在这里,以防你的情况足够
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.