python能读取tsv吗

python能读取tsv文件。方法为:1、导入pandas模块;2、输入“train=pd.read_tsv('test.tsv',sep='\t')”命令,即使用pandas调用read()方法读取tsv文件。

python能读取tsv吗

使用pandas读取tsv文件的代码如下:

train=pd.read_csv('test.tsv',sep='\t')

如果已有表头,则可使用header参数:

train=pd.read_csv('test.tsv',sep='\t',header=0)

如果已有主键列:

train=pd.read_csv('test.tsv',sep='\t',header=0,index_col='id')