i need convert .csv specific .json format, , decided use csvtojson package npm since seemed designed sort of thing.
first, little background on problem. have .csv data looks similar this:
scan_type, date/time, source address, source-lat, source-lng, dest address, dest-lat, dest-lng nexpose,2016-07-18 18:21:44,1008,40.585260,-10.124120,10.111.131.4,10.844880,-10.933360
i have plain csv-to-json converter here , there problem. outputs rather plain file, , need split source/destination, , add special formatting show later on.
[ { "scan_type": "nexpose", "date/time": "2026-07-28 28:22:44", "source_address": 2008, "source-lat": 10.58526, "source-lng": -105.08442, "dest_address": "11.266.282.0", "dest-lat": 11.83388, "dest-lng": -111.82236 } ]
the first thing need able separate "source" values, "destination" values. here example of want "source" values like:
(var destination same format)
var source={ id: "99.58926-295.09492", "source-lat": 49.59926, "source-lng": -209.98942, "source_address": 2009, x: { valueof: function() { var latlng=[ 49.58596, -209.08442 ]; var xy = map.function_for_converting_lat_lng_to_x_y(latlng); return xy[0]; //xy.x }, y: { valueof: function(){ varlatlng=[ 49.58596, -209.08442 ]; var xy = map.function_for_converting_lat_lng_to_x_y(latlng); return xy[1]; //xy.y } }
so, question is, how should approach converting data? should convert csvtojson? or should convert plain .json file generated?
does have advice, or similar examples, share on how approach problem?
i lot of work parsing csv data , sure have seen, csv hard parse , work correctly there huge number of edge cases can break rugged of parsers (although looks dataset plain isn't huge concern). not mention potentially run corruption performing operations while reading disk, better idea data csv json file , make manipulations json object loaded "plain" json file.
tl;dr: convert data plain .json file
Comments
Post a Comment