<commit_before>require 'bundler'
Bundler.require

require 'csv'

COLUMNS = %w(
  legacy_id
  first_name
  last_name
  family_legacy_id
  family_name
  family_last_name
  family_address1
  family_address2
  family_city
  family_state
  family_zip
  family_country
).freeze

(DATA_PATH, OUT_PATH) = ARGV

me = DBF::Table.new(File.join(DATA_PATH, 'me.dbf'))
ma = DBF::Table.new(File.join(DATA_PATH, 'ma.dbf'))

families = ma.each_with_object({}) { |f, h| h[f['MAIL_NO']] = f }

CSV.open(OUT_PATH, 'w') do |csv|
  csv << COLUMNS
  me.each do |person|
    print '.'
    family = families[person['MAIL_NO']]
    csv << [
      person['PERS_NO'],
      person['FIRSTNAME'].strip,
      person['LASTNAME'].strip,
      person['MAIL_NO'],
      family['NAMELINE'].strip,
      family['LASTNAME'].strip,
      family['ADDRESS'].strip,
      family['ADDRESS2'].strip,
      family['CITY'].strip,
      family['STATE'].strip,
      family['ZIP'].strip,
      family['COUNTRY'].strip<commit_msg>Show more helpful error if no args passed<commit_after>require 'bundler'
Bundler.require

require 'csv'

COLUMNS = %w(
  legacy_id
  first_name
  last_name
  family_legacy_id
  family_name
  family_last_name
  family_address1
  family_address2
  family_city
  family_state
  family_zip
  family_country
).freeze

(DATA_PATH, OUT_PATH) = ARGV

unless DATA_PATH && OUT_PATH
  puts 'ERROR: You must pass path to database and path for output csv file'
  exit 1
end

me = DBF::Table.new(File.join(DATA_PATH, 'me.dbf'))
ma = DBF::Table.new(File.join(DATA_PATH, 'ma.dbf'))

families = ma.each_with_object({}) { |f, h| h[f['MAIL_NO']] = f }

CSV.open(OUT_PATH, 'w') do |csv|
  csv << COLUMNS
  me.each do |person|
    print '.'
    family = families[person['MAIL_NO']]
    csv << [
      person['PERS_NO'],
      person['FIRSTNAME'].strip,
      person['LASTNAME'].strip,
      person['MAIL_NO'],
      family['NAMELINE'].strip,
      family['LASTNAME'].strip,
      family['ADDRESS'].strip,
      family['ADDRESS2'].strip,
      family['CITY'].strip,
      family['STATE'].strip,
      family['ZIP'].strip,
      family['COUNTRY'].strip
{'fraction_non_alphanumeric': 0.15016579819990525, 'fraction_numerical': 0.0033159639981051635, 'mean_word_length': 3.611353711790393, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '620897', 'n_tokens_mistral': 780, 'n_tokens_neox': 775, 'n_words': 146}