我有一些输入文件如下所示:
GENE CHR START STOP NSNPS NPARAM N ZSTAT P
2541473 1 1109286 1133315 2 1 15000 3.8023 7.1694e-05
512150 1 1152288 1167447 1 1 15000 3.2101 0.00066347
3588581 1 1177826 1182102 1 1 15000 3.2727 0.00053256我正在导入这样的文件:
df = pd.read_csv('myfile.out', sep='\t')但是所有的数据都会被读取到一个列中。我尝试过将文件格式更改为encoding='utf-8'、encoding='utf-16-le'、encoding='utf-16-be',但这是行不通的。sep=' '的分离会将数据分隔成太多的列,但它会分离。有办法正确地读取这些数据吗?
发布于 2022-01-28 22:02:33
尝试使用\s+ (读取为“一个或多个空白字符”)作为分隔符:
df = pd.read_csv('myfile.out', sep='\s+')https://stackoverflow.com/questions/70900745
复制相似问题