所以,我目前转移一个txt文件到CSV。这主要是清理,但即使分裂后仍然有一些我的数据之间的空列。
Sat_File = '/Users'
output = '/Users2'
import csv
import matplotlib as plt
import pandas as pd
with open(Sat_File,'r') as sat:
with open(output,'w') as outfile:
if "2004" in line:
line=line.split(' ')
writer=csv.writer(outfile)
writer.writerow(line)
基本上,我只是想消除我所提供的CSV图片列之间的差距。谢谢!
您可以使用Python熊猫库,以清除空列:
import pandas as pd
df = pd.read_csv('path_to_csv_file').dropna(axis=1, how='all')
df.to_csv('path_to_clean_csv_file')
基本上我们:
$$$ Pr0f T!$$$