bmr-cymru / csv2kml

Simple script to convert DGI black box CSV data to KML
GNU General Public License v2.0
0 stars 0 forks source link

Field Map wrong #5

Closed aseedig closed 6 years ago

aseedig commented 6 years ago

Since the last fix I see the following error when using the attached CSV file.

Axels-MacBook-Pro:AUDS aseedig$ /Users/aseedig/src/git/csv2kml/csv2kml.py -i M16_N1.csv -o M16_N1_Marker.kml -p -t 0 -vvv --debug
INFO - Processing CSV data from M16_N1.csv
DEBUG - wrote KML headers
DEBUG - wrote icon style (href='http://www.earthpoint.us/Dots/GoogleEarth/pal2/icon13.png')
DEBUG - wrote icon style (href='http://www.earthpoint.us/Dots/GoogleEarth/shapes/target.png')
DEBUG - wrote icon style (href='http://maps.google.com/mapfiles/kml/paddle/D.png')
DEBUG - wrote style headers
DEBUG - parsing field map from header row
DEBUG - mapping field F_YAW to index 3 ('Bearing')
DEBUG - mapping field F_FLY_STATE to index 2 ('Identify')
DEBUG - mapping field F_FLIGHT_TIME to index 8 ('Tick#')
DEBUG - mapping field F_TRAVEL_DIST to index 4 ('Distance')
DEBUG - mapping field F_GPS_LONG to index 6 ('Target_Lon')
DEBUG - mapping field F_BASE_LONG to index 9 ('Base_Lon')
DEBUG - mapping field F_GPS_ALT to index 5 ('Height')
DEBUG - mapping field F_TICK to index 8 ('Tick#')
DEBUG - mapping field F_BASE_LAT to index 10 ('Base_Lat')
DEBUG - mapping field F_GPS_TS to index 0 ('Time_Stamp')
DEBUG - mapping field F_GPS_LAT to index 7 ('Target_Lat')
DEBUG - mapping field F_BASE_ALT to index 11 ('Base_Alt')
DEBUG - built field map with 16 fields
DEBUG - field map: {'F_POLY_LONG_1': -1, 'F_POLY_LONG_2': -1, 'F_YAW': 3, 'F_FLY_STATE': 2, 'F_POLY_LAT_1': -1, 'F_FLIGHT_TIME': 8, 'F_TRAVEL_DIST': 4, 'F_POLY_LAT_2': -1, 'F_GPS_LONG': 6, 'F_BASE_LONG': 9, 'F_GPS_ALT': 5, 'F_TICK': 8, 'F_BASE_LAT': 10, 'F_GPS_TS': 0, 'F_GPS_LAT': 7, 'F_BASE_ALT': 11}
Traceback (most recent call last):
  File "/Users/aseedig/src/git/csv2kml/csv2kml.py", line 1099, in <module>
    ret = main(sys.argv)
  File "/Users/aseedig/src/git/csv2kml/csv2kml.py", line 1084, in main
    csv2kml(args)
  File "/Users/aseedig/src/git/csv2kml/csv2kml.py", line 1027, in csv2kml
    track_color=track_color, field_map=field_map)
  File "/Users/aseedig/src/git/csv2kml/csv2kml.py", line 753, in process_csv
    ts = int(getfield(F_TICK)) if getfield(F_TICK) else None
ValueError: invalid literal for int() with base 10: '55.05515216'

The index seem to be one off. Tick# is detected as index 8, but pulls the values from index 7 (Target_Lon).

(EDIT): Had to attache the file as .txt since CSV is not supported... PONDER M16_N1.txt

bmr-cymru commented 6 years ago

(EDIT): Had to attache the file as .txt since CSV is not supported... PONDER

For something that size it's easiest to just paste it into the comment. Start and end the quote with three backticks (```) on a line by themselves:

Time_Stamp,Track #,Identify,Bearing,Distance,Height,Target_Lon,Target_Lat,Tick#,Base_Lon,Base_Lat,Base_Alt
27/02/2018 13:43,0,Phantom launch,1.9,206.8861947,6.863121926,-2.563252210,55.05510464,27,-2.563872,55.056931,5
27/02/2018 13:44,0,"Flying left to right, right to left",1.9,198.890593,6.597880499,-2.563545590,55.05515216,28,-2.563872,55.056931,5
27/02/2018 13:44,0,Approaching from the front,6,163.1015908,17.14266798,-2.563038282,55.05554412,29,-2.563872,55.056931,5
27/02/2018 13:45,0,Flying behind the Radar. Still have E/O tracking,9.7,0,0,-2.563872000,55.05693100,30,-2.563872,55.056931,5
27/02/2018 13:46,0,Still behind. E/O tracking,10.8,0,0,-2.563872000,55.05693100,31,-2.563872,55.056931,5
27/02/2018 13:47,0,Still behind E/O tracking,11,0,0,-2.563872000,55.05693100,32,-2.563872,55.056931,5
27/02/2018 13:48,0,E/O Tracking still,12.6,0,0,-2.563872000,55.05693100,33,-2.563872,55.056931,5
27/02/2018 13:48,0,Behind still E/O tracking,12.9,0,0,-2.563872000,55.05693100,34,-2.563872,55.056931,5
27/02/2018 13:50,0,Flying to front back on Radar and E/O going right,15.2,0,0,-2.563872000,55.05693100,35,-2.563872,55.056931,5
27/02/2018 13:51,0,Rapid flying left to right,0.3,213.9970665,1.12049626,-2.562452057,55.05518681,36,-2.563872,55.056931,5
27/02/2018 13:52,0,Flying left to right,1.4,213.9361188,5.228486125,-2.562142027,55.05528185,37,-2.563872,55.056931,5
27/02/2018 13:52,0,0,2.5,213.7963194,9.334548896,-2.561994939,55.05533701,38,-2.563872,55.056931,5
27/02/2018 13:52,0,Flying left to right,4,0,0,-2.563872000,55.05693100,39,-2.563872,55.056931,5
27/02/2018 13:53,0,Move to low level,-3.3,268.5539487,-15.48472325,-2.562360980,55.05467628,40,-2.563872,55.056931,5
27/02/2018 13:54,0,Low level down the road. Radar and E/O track,-3.3,338.4378758,-19.51420514,-2.560900696,55.05440771,41,-2.563872,55.056931,5
27/02/2018 13:55,0,Hover. Radar and E/O track,-2.3,389.6858141,-15.65139909,-2.558985767,55.05482186,42,-2.563872,55.056931,5
27/02/2018 13:56,0,Landing (capture) ,-3.1,354.480518,-19.19797861,-2.559427182,55.05501241,43,-2.563872,55.056931,5

See the "Styling with Markdown is supported" link for more details.

aseedig commented 6 years ago

There was a comma in the description field in line 2. This caused the problem.