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