我正在尝试将FEC的“个人贡献”(indiv18.zip)(可在此处找到:https://classic.fec.gov/finance/disclosure/ftpdet.shtml#a2017_2018)读入python。它被下载到几个.txt文件中。我很新,我很困惑如何将这些文件读入python。非常感谢!
答案 0 :(得分:1)
先下载文件,然后解压缩
尝试此代码
import pandas as pd
with open("cm.txt", "r", newline="") as f:
table = pd.read_table(f, sep='|',lineterminator='\n')
print (table[:0])
输出
Empty DataFrame
Columns: [C00000018, IRONWORKERS LOCAL UNION NO. 25 POLITICAL EDUCATION COMMITTEE, STEVEN N GULICK, 43335 W 10 MILE, P O BOX 965, NOVI, MI, 48050, U, Q, Unnamed: 10, T, Unnamed: 12, IRON WORKERS; INT'L ASS'N OF BRIDGE..., H8TX22313]
Index: []
的信息