<commit_before>module Fech
  class Committee

    DETAIL_COLS = [:committee_id, :committee_name, :treasurer, :street_one, :street_two, :city, :state, :zipcode, :designation, :type, :party, :filing_frequency, :category, :connected_organization, :candidate_id]
    SUMMARY_COLS = [:committee_id, :committee_name, :type, :designation, :filing_frequency, :total_receipts, :transfers_from_affiliates, :individual_contributions, :pac_contributions, :candidate_contributions, 
        :candidate_loans, :total_loans_received, :total_disbursements, :transfers_to_affiliates, :individual_refunds, :committee_refunds, :candidate_loan_repayments, :loan_repayments, :beginning_year_cash, 
        :ending_cash, :debts_owed_by, :nonfederal_transfers_received, :contributions_to_committees, :independent_expenditures, :party_coordinated_expenditures, :nonfederal_share_expenditures, :coverage_end_date]

    # corresponds to the FEC Committee master file described here:
    # http://www.fec.gov/finance/disclosure/metadata/DataDictionaryCommitteeMaster.shtml
    def self.detail(cycle)
      url = "ftp://ftp.fec.gov/FEC/#{cycle}/cm#{cycle.to_s[2..3]}.zip"
      t = RemoteTable.new url, :filename => "cm.txt", :col_sep => "|", :headers => DETAIL_COLS
      t.entries
    end
    
    # http://www.fec.gov/finance/disclosure/metadata/DataDictionaryWEBK.shtml<commit_msg>added write_to_csv method to Committee<commit_after>module Fech
  class Committee

    DETAIL_COLS = [:committee_id, :committee_name, :treasurer, :street_one, :street_two, :city, :state, :zipcode, :designation, :type, :party, :filing_frequency, :category, :connected_organization, :candidate_id]
    SUMMARY_COLS = [:committee_id, :committee_name, :type, :designation, :filing_frequency, :total_receipts, :transfers_from_affiliates, :individual_contributions, :pac_contributions, :candidate_contributions, 
        :candidate_loans, :total_loans_received, :total_disbursements, :transfers_to_affiliates, :individual_refunds, :committee_refunds, :candidate_loan_repayments, :loan_repayments, :beginning_year_cash, 
        :ending_cash, :debts_owed_by, :nonfederal_transfers_received, :contributions_to_committees, :independent_expenditures, :party_coordinated_expenditures, :nonfederal_share_expenditures, :coverage_end_date]

    def self.write_to_csv(method, cycle)
      headers = method == 'detail' ? DETAIL_COLS : SUMMARY_COLS
      rows = self.send(method, cycle)
      Fech::Utilities.write_to_csv("committees_#{method}_#{cycle}", headers, rows)
    end

    # corresponds to the FEC Committee master file described here:
    # http://www.fec.gov/finance/disclosure/metadata/DataDictionaryCommitteeMaster.shtml
    def self.detail(cycle)
      url = "ftp://ftp.fec.gov/FEC/#{cycle}/cm#{cycle.to_s[2..3]}.zip"
      t = RemoteTable.new url, :filename => "cm.txt", :col_sep => "|", :headers => DETAIL_COLS
      t.entries
    end
    
    # http://www.fec.gov/finance/disclosure/metadata/DataDictionaryWEBK.shtml
{'fraction_non_alphanumeric': 0.11936785474108944, 'fraction_numerical': 0.0013449899125756557, 'mean_word_length': 5.87066974595843, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2611721', 'n_tokens_mistral': 1089, 'n_tokens_neox': 997, 'n_words': 164}