使用panda将已解码的zip文件转换为.txt文件时出错(已解码的文件在开始时缺少\t‘)

import gzip
input_file = open("example.bed","rb")#compress existing file
data = input_file.read()

with gzip.open("example.bed.gz", "wb") as filez:
filez.write(data)
filez.close()
fileopen= gzip.open("example.bed.gz", "r+") 
output=fileopen.read()

decode=output.decode("utf-8")
import pandas as pd
df=pd.read_csv(decode, delimiter='\t',header=1 )#Works partially, missing '\t' at start of file throws error
df.to_csv('exampleziptotxt.bed', index=False)

使用pandas将.bed压缩文件转换为.txt文件。文件的开头是chr8\t..。因为没有前导文件,所以返回FileNotFoundError: errno2File chr8。如何更正输入文件以使其包含前导\t的建议

转载请注明出处:http://www.lvguanye.net/article/20230526/2241364.html