Last active
December 28, 2015 06:09
-
-
Save unRob/7455249 to your computer and use it in GitHub Desktop.
mercaditoses
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
require 'CSV' | |
require 'json' | |
features = [] | |
CSV.foreach('./mercados.csv', headers: true).each do |line| | |
# Obviamente no todos traen lat/lng, y no siempre es nil, a veces es NULL | |
# porque BUROCRACIA, THAT'S WHY | |
next if line['longitud'] == 'NULL' || line['longitud'] == "0" | |
features << { | |
geometry: { | |
coordinates: [line['longitud'], line['latitud']].map(&:to_f), | |
type: 'Point' | |
}, | |
properties: { | |
nombre: line['nombre'], | |
fid: line['fid'].to_i, | |
locales: line['locales'], | |
tipo: line['tipo_desc'], | |
actualizado: line['actualizado'], | |
delegacion: line['delegacion'] | |
}, | |
type: 'Feature' | |
} | |
end | |
puts ({type: 'FeatureCollection', features: features}).to_json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment