I'm trying to read the FEC's "contributions by individuals" (indiv18.zip), (available here: https://classic.fec.gov/finance/disclosure/ftpdet.shtml#a2017_2018 ) into python. It comes downloaded into several .txt files. I'm very new and I'm confused how I can read these files into python. Thanks so much!
Download the file first,then unzip it
Try this code
import pandas as pd
with open("cm.txt", "r", newline="") as f:
table = pd.read_table(f, sep='|',lineterminator='\n')
print (table[:0])
Output
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: []
Read about pandas.read_table
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.