我想读取由','分隔的txt数据。和' \ t',我使用下面的代码:
io_df = pd.read_csv('input_output.txt',sep='\D|\t',engine = 'python')
此触发的错误信息如下:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-38-5ab0138d93ac> in <module>()
----> 1 io_df = pd.read_csv('input_output.txt',sep='\D|\t',engine = 'python')
如何解决这个问题?
答案 0 :(得分:0)
对我而言sep=",|\t"
:
pd.read_csv('test.csv', sep=",|\t", engine = 'python')
样品:
import pandas as pd
df = pd.read_csv('https://dl.dropboxusercontent.com/u/84444599/test.csv',
sep=",|\t",
engine = 'python')
print (df)
col col1 col2
0 a d t
1 d u l