ruby on rails - Join country calling codes to country table list -


i creating rails project requires country table. include country calling codes them. found in creating country table github , looks this:

class createcountries < activerecord::migration   def change     create_table :countries |t|       t.string :name       t.string :printable_name       t.string :iso2, :size => 2       t.string :iso3, :size => 3       t.integer :numcode        t.timestamps     end   end    country.reset_column_information    country.create(:iso2 => 'af', :name => 'afghanistan', :printable_name => 'afghanistan', :iso3 => 'afg', :numcode => '004')   country.create(:iso2 => 'al', :name => 'albania', :printable_name => 'albania', :iso3 => 'alb', :numcode => '008')   country.create(:iso2 => 'dz', :name => 'algeria', :printable_name => 'algeria', :iso3 => 'dza', :numcode => '012') 

and i've found list of country calling codes , managed put them in spreadsheet:

afghanistan 93 albania 355 algeria 213 

what i'd fast way join calling code above list looks this:

country.create(:iso2 => 'af', :name => 'afghanistan', :printable_name => 'afghanistan', :iso3 => 'afg', :numcode => '004' :call_code => 93) 

any fast solution achieve using excel or openoffice spreadsheet or mysql? long dont have key in manually.

  1. copy country.create lines of code excel, starting in a1.
  2. copy list of codes excel , if necessary split 2 columns (eg text columns).
  3. name result (say carray).
  4. in b1 put: =find("printable_name => '",a1)+19.
  5. in c1 put:

    =substitute(a1,")"," :call_code => "&vlookup(mid(a1,b1,find("'",a1,b1)-b1),carray,2,0)&")")   
  6. copy b1:c1 down suit.

  7. copy of columnc in code suitable.

carray need not in same sheet.


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -