nytimes / Fech

Deprecated. Please see https://github.com/dwillis/Fech for a maintained fork.
http://nytimes.github.io/Fech/
Other
114 stars 30 forks source link

How can I download specifc FEC filing download as csv with specific form type? #81

Closed ahmedmohiduet closed 8 years ago

ahmedmohiduet commented 8 years ago

I am downloading every filing using my this codes: filing = Fech::Filing.new(1029398) filing.download Now I have my filing at /tmp/1029398.fec http://docquery.fec.gov/cgi-bin/forms/C00580100/1029398/ is a F3P type form But my this *.fec filetype looks completely unknown to me. I have opened it in Excel and the content looks scary: image

Can I download this file as F3P.csv file like this format: https://github.com/dwillis/fech-sources/blob/master/F3P.csv I have looked through the documentation http://nytimes.github.io/Fech/ But couldnt find any similar options

dwillis commented 8 years ago

The .fec filetype is simply a delimited text file. Fech doesn't just download the filing, it also parses it into Ruby objects or raw CSV text if you like. It automatically parses it based on the form type.

ahmedmohiduet commented 8 years ago

So I can actually save it as a https://github.com/dwillis/fech-sources/blob/master/F3P.csv file if it's form type is F3P right? But how can I do it in my ruby script?

dwillis commented 8 years ago

Take a look at the examples here: http://nytimes.github.io/Fech/

Fech converts each filing's data into Ruby objects or you can access each row as raw data using :raw => true on a specific row type. If you want contributions, you can specify filing.contributions, for example. Can you tell me more about what you'd specifically like to do?

ahmedmohiduet commented 8 years ago

Thank you dwillis! I am actually sorry for asking confusing questions. Actually I am kinda confused about how the whole thing working. I guess I have to go through this documentation a bit more. All I'm trying is downloading every F3P filings as CSVs.

dwillis commented 8 years ago

Ok, that's a reasonable goal :-)

You should know that the filings contain multiple types of rows, in terms of record layouts (a typical F3P has both contributions and expenditures, plus summary data, for example). That's why Fech maps those rows to Ruby objects. So if you want to save them as CSVs, you probably will want to divide the row types into individual CSV files rather than just saving the entire filings as a CSV (but you can do that, too, by using raw and writing the filing's contents to a CSV file).

ahmedmohiduet commented 8 years ago

Thank you dwillis! I guess I have to go with, storing separate CSVs! :)