#!/bin/bash # Files: vds_config_d12.csv is the config file with VDS lat/long and other identifying data # 5minagg_latest.txt is the 5 min aggregate real time data. We need two fields: id and speed. # # FIRST: Remove first line of 5minagg (contains date). tail -n+2 5minagg_latest.txt > 5min_latest_tail.txt # SECOND: sort it sort 5min_latest_tail.txt > 5min_latest_sorted.txt # Join the two files on the ID field, appending speed as the last field join -t"," 5min_latest_sorted.txt vds_config_d12ML_sorted.csv -o 1.1,2.2,2.6,2.7,2.9,2.11,2.12,1.4 > vds_speeds.csv # #3. Run this awk program to convert output csv to geojson # # Convert a csv with postmile and coordinates to a json file # Note it switches lat/long to long/lat # Sample invocation: # Determine how many lines in file eof=`wc vds_speeds.csv | cut -f3 -d" " ` # Pass that as parameter to awk program, who uses it to not print a comma after last record. awk -F',' -v eof="$eof" -f csvToGson.awk vds_speeds.csv > vds_speeds.gson # Copy result from jdalbey home to dynamic_data folder on server cp vds_speeds.gson /web/webapps/realtime_VDS/dynamicdata/vds_realtime.gson