我想把一些处理工作从R转移到Python。在R中,我使用read.table()函数来读取非常混乱的CSV文件,并且它会自动将记录以正确的格式分割。例如:
391788,"HP Deskjet 3050 scanner always seems to break","<p>I'm running a Windows 7 64 blah blah blah........ake this work permanently?</p>
<p>Update: It might have something to do with my computer. It seems to work much better on another computer, windows 7 laptop. Not sure exactly what the deal is, but I'm still looking into it...</p>
","windows-7 printer hp"
正确地分成了4列。1条记录可以分成多行,并且逗号随处可见。在R中,我只需要这样做:
read.table(infile, header = FALSE, nrows=chunksize, sep=",", stringsAsFactors=FALSE)
有没有Python中的工具能够同样做到这个功能呢? 谢谢!