Taking CSV Exported Cube Voyager Path Files to A New Level Using GAWK (part 1)
In a prior post, I link to some code that outputs a path file. Â I’ve done something a tad different because I needed some select link analysis and reading the path file in Cube was taking far too long to do it the normal way.
So, I took that program on Github and extended it to perform a selected link:
//Check for specific nodes | |
bool output=false; | |
for(int pn=1;pn<prrn-1;pn++){ | |
if(prd.nodes[pn]==9798 && prd.nodes[pn+1]==9750) | |
output=true; | |
} | |
if(output){ | |
of.open(argv[2],iostream::trunc); | |
of << prd.I << ","; | |
for(int pn=0;pn<prrn;pn++){ | |
of << prd.nodes[pn]; | |
if(prd.nodes[pn]!=prd.J) | |
of <<","; | |
} | |
of << endl; | |
of.close(); | |
} |
And this outputs a few GB of paths in CSV format. Â I went from 42 GB of paths in the AM to 3.4 GB of CSV paths. Â Still not good enough. The next thing I did was use GAWK to get just the Origin and Destination
gawk 'BEGIN {FS=","};{print $1,",",$NF}' amPaths.csv >amOD.CSV |
This returns a CSV file of just the origin and destination (which can be linked to the vehicle trip matrix).
Part 2 will discuss how to link to a vehicle trip matrix and if this approach actually works!
Tags: awk, csv files, cube, gawk, path files, select link