这会起作用。它回退到python解析器(因为您有非常规分隔符,例如,它们是逗号,有时是空格)。如果只有逗号,它将使用c解析器并且速度更快。
In [1]: import csvIn [2]: !cat test.csv"column1","column2", "column3", "column4", "column5", "column6""AM", "07", "1", "SD", "SD", "CR""AM", "08", "1,2,3", "PR,SD,SD", "PR,SD,SD", "PR,SD,SD""AM", "01", "2", "SD", "SD", "SD"In [3]: pd.read_csv('test.csv',sep=',s+',quoting=csv.QUOTE_ALL)pandas/io/parsers.py:637: ParserWarning: Falling back to the 'python' engine because the 'c' engine does not support regex separators; you can avoid this warning by specifying engine='python'. ParserWarning)Out[3]: "column1","column2" "column3" "column4" "column5" "column6""AM" "07" "1" "SD" "SD" "CR""AM" "08" "1,2,3" "PR,SD,SD" "PR,SD,SD" "PR,SD,SD""AM" "01" "2" "SD" "SD" "SD"
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)