Class: TelephoneNumber::GeoLocationDataImporter
- Inherits:
-
Object
- Object
- TelephoneNumber::GeoLocationDataImporter
- Defined in:
- lib/importers/geo_location_data_importer.rb
Class Method Summary collapse
Class Method Details
.load_data! ⇒ Object
3 4 5 |
# File 'lib/importers/geo_location_data_importer.rb', line 3 def self.load_data! Dir.glob("data/geocoding/**/*.txt").each { |file| process_file(file) } end |
.process_file(file_path) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/importers/geo_location_data_importer.rb', line 7 def self.process_file(file_path) master_data = {} bin_file_path = "#{File.dirname(file_path)}/#{File.basename(file_path, '.txt')}.dat" File.open(file_path, 'r:UTF-8').each do |row| next if row.strip !~ /^[0-9]/ number, location = row.split('|') master_data[number.strip] = location.strip end File.open(bin_file_path, 'wb'){ |file| file << Marshal.dump(master_data) } end |