How to parse the string entries read from a file into their struct / types?

I was reading a text file, which has the following columns: startTimes, startLocs, planedRouteNds, edgesDists, edgesTravelTimes, dists, durationTimes, and eventCtgrs. Each one of them has a different type. For example, startTimes is of type Float64, startLocs is of type LLA, planedRouteNds is of type Array{LLA,1}, edgesDists is of type Array{Float64,1}, edgesTravelTimes is of type Array{Float64,1}, dists is of type Float64, durationTimes is of type Float64 and eventCtgrs is of type EventCtgrs. I read the whole file by readlines, and then process the obtained array line by line. The tricky part is that, readlines will read the whole file into an array of lines, with each line a string. I can split the string into separate cells, but the question is, how to parse the string cells into its corresponding typed entries? Or is there any better way to do this? Any comments are greatly appreciated.

Could you give a small example of how such a file would look like? I think that would help the answers.

startTime,startLoc,planedRouteNds,edgesDists,edgesTravelTimes,dist,durationTime,eventCtgr
0.0;LLA(66.54406322195405, 23.143566102684176, 0.0);Any;Any;Any;0;-1.0;vehicleGetReady;
71.32207701198374;LLA(66.50569110246629, 12.73100700341307, 0.0);LLA[LLA(66.0685394, 14.8741299, 0.0), LLA(66.0497297, 14.8968747, -1.862645149230957e-9),…

I’m sorry, I can’t quite make out what I’m looking at. Is that one row? Could possibly you format and annotate the example?

1 Like

header is as the following:
startTime,startLoc,planedRouteNds,edgesDists,edgesTravelTimes,dist,durationTime,eventCtgr
First line:
0.0;LLA(66.54406322195405, 23.143566102684176, 0.0);Any;Any;Any;0;-1.0;vehicleGetReady;
part of second line:
71.32207701198374;LLA(66.50569110246629, 12.73100700341307, 0.0);LLA[LLA(66.0685394, 14.8741299, 0.0), LLA(66.0497297, 14.8968747, -1.862645149230957e-9),…

So… is this all valid Julia code? If so, how did you come to this file? Maybe there is a way to do this more elegantly.