Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Friendly field names #5

Open
beechnut opened this issue Jul 12, 2013 · 0 comments
Open

[Enhancement] Friendly field names #5

beechnut opened this issue Jul 12, 2013 · 0 comments

Comments

@beechnut
Copy link
Contributor

At present, you pass in fields that are just the codes listed in the Census reference handbook. This provides reliability, but it's not very Rubyish.

I think it's possible to let people specify field components by text, which are looked up in a YAML file / Hash to construct the field code.

Example:

field = Field.new(:total_population, :total, :white, :total)
field.code
# => 'P0010001'

@client.find( field, county: 'Suffolk', state: 'MA' )
# => [{"P0010001"=>"722023", "name"=>"Suffolk County", "state"=>"25", "county"=>"025"}] 

# or specify the table name directly, which returns the first field for that table
@client.find( :total_population, county: 'Suffolk', state: 'MA' )
# => [{"P0010001"=>"722023", "name"=>"Suffolk County", "state"=>"25", "county"=>"025"}] 

field_hh = Field.new(:household_type, :other_family)
field_hh.code
#=> 'P0180004'

Field Construction

Field codes appear to have a highly structured construction, but the principles behind it are not clearly laid out anywhere in the census docs. From cursory research, they look like:

P001A0001

  • Table Type: P
  • Table Indicator: 001 (in Census docs, it's just P1. Any table indicator is formatted with a %3d.
  • (Optional) Race Indicator: A
  • Field Code:

Or, as an object (looks like YAML a little...):

P: Population
  001: Total (Population)
    A: White
      0001: Total 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants