Sha256: 11b12cc80d3106c72dff2c49ec710edc4ca747e7e2fced70a4f8e3ad886f0b01

Contents?: true

Size: 1.89 KB

Versions: 26

Compression:

Stored size: 1.89 KB

Contents

$LOAD_PATH.unshift("xampl_generated_code")

require 'set'
require 'fastercsv'
require 'RandomPeople'
require 'people'

Xampl.set_default_persister_kind(:tokyo_cabinet)
Xampl.set_default_persister_format(:xml_format)

module RandomPeople
  arr_of_arrs = FasterCSV.read("random-names.csv")

  surnames = Set.new
  cities = Set.new
  states = Set.new
  email_domains = Set.new

  arr_of_arrs.each do | row |
    surname = row[1]
    city = row[3]
    state = row[4]

    surnames << surname
    cities << city
    states << state

    email = row[6]
    domain = email.split("@")
    if 2 == domain.size then
      email_domains << domain[1]
    end

  end

  puts "surnames: #{ surnames.size }"
  puts "cities: #{ cities.size }"
  puts "states: #{ states.size }"
  puts "email_domains: #{ email_domains.size }"

  puts "STATES:"
  puts states.to_a.sort.inspect

  puts "EMAIL DOMAINS:"
  puts email_domains.to_a.sort.inspect

  #GivenName,Surname,StreetAddress,City,State,ZipCode,EmailAddress,TelephoneNumber
  #<people pid='' xmlns="http://xampl.com/people">
  #    <person pid=''
  #            given-name=''
  #            surname=''
  #            street-address=''
  #            city=''
  #            state=''
  #            postal-code=''
  #            email=''
  #            phone=''/>
  #</people>

#  Xampl.transaction("random-people") do
#
#    people = People.new('people')
#
#    arr_of_arrs.each_with_index do | row, i |
#      person = people.new_person("person-#{ i }")
#      person.given_name = row[0]
#      person.surname = row[1]
#      person.street_address = row[2]
#      person.city = row[3]
#      person.state = row[4]
#      person.postal_code = row[5]
#      person.email = row[6]
#      person.phone = row[7]
#    end
#  end
#
#  processed_at = Time.now
#
#  p counts
#  p "parsed in #{ parsed_at - start_at }, counted in: #{ counted_at - parsed_at }, processed in: #{ processed_at - counted_at }"

end

Version data entries

26 entries across 23 versions & 2 rubygems

Version Path
hutch-xamplr-1.0.0 examples/random-people/what-to-query-on.rb
hutch-xamplr-1.0.1 examples/random-people/what-to-query-on.rb
hutch-xamplr-1.0.2 examples/random-people/what-to-query-on.rb
hutch-xamplr-1.0.3 examples/random-people-shared-addresses/what-to-query-on.rb
hutch-xamplr-1.0.3 examples/random-people/what-to-query-on.rb
hutch-xamplr-1.0.4 examples/random-people/what-to-query-on.rb
hutch-xamplr-1.0.4 examples/random-people-shared-addresses/what-to-query-on.rb
hutch-xamplr-1.0.5 examples/random-people/what-to-query-on.rb
hutch-xamplr-1.0.5 examples/random-people-shared-addresses/what-to-query-on.rb
hutch-xamplr-1.1.0 examples/random-people-shared-addresses/what-to-query-on.rb
hutch-xamplr-1.1.1 examples/random-people-shared-addresses/what-to-query-on.rb
hutch-xamplr-1.1.2 examples/random-people-shared-addresses/what-to-query-on.rb
hutch-xamplr-1.1.4 examples/random-people-shared-addresses/what-to-query-on.rb
hutch-xamplr-1.2.0 examples/random-people-shared-addresses/what-to-query-on.rb
hutch-xamplr-1.3.0 examples/random-people-shared-addresses/what-to-query-on.rb
hutch-xamplr-1.3.1 examples/random-people-shared-addresses/what-to-query-on.rb
hutch-xamplr-1.3.10 examples/random-people-shared-addresses/what-to-query-on.rb
hutch-xamplr-1.3.11 examples/random-people-shared-addresses/what-to-query-on.rb
hutch-xamplr-1.3.12 examples/random-people-shared-addresses/what-to-query-on.rb
hutch-xamplr-1.3.13 examples/random-people-shared-addresses/what-to-query-on.rb