Sorry, beginner here. I feel this should be simple but I'm struggling...
I'm reading a set of race timing data from a web site and want to manipulate it into a list of lists that I can then export to a CSV file for later reading into a database.
Here are three example result rows:
d = {{50, "M370", "John Doe", "Honda", 2.24, 56, 17.26, 24.38, 33.52,
38.69, 45.52, 53.69, "Practice"}, {51, "M398", "Jane Doe",
"KTM", 2.49, 52, 57.03, 47.51, "FAIL", "Practice"}, {56, "M553",
"John Wayne", "Husqvarna", 2.54, 53, "FLAG", "Practice"}}
The first row (John Doe) is a normal, 13-column wide result row and I want to add a 14th column with the value "False".
The second row (Jane Doe) is an example of a 'fail' which is where the competitor crashed or came off the track. In this case I just want to change
{51, "M398", "Jane Doe", "KTM", 2.49, 52, 57.03, 47.51, "FAIL", "Practice"}
into
{51, "M398", "Jane Doe", "KTM", 2.49, 52, 57.03, 47.51, 0, 0, 0, 0, "Practice", "False"}
i.e. remove the word "Fail", insert zeros as time placeholders and set column 14 value to 'false'.
Finally, if the competitor ahead (competitors start at 30 sec intervals) has a crash then the current competitor (John Wayne) is "flagged" and they get to go again. In this case I want to do change:
{56, "M553", "John Wayne", "Husqvarna", 2.54, 53, "FLAG", "Practice"}
into
{56, "M553", "John Wayne", "Husqvarna", 2.54, 53, 0, 0, 0, 0, 0, 0, "Practice", "True"}
I tried using Position[d, "FLAG", 2] to find "Flag entries but I'm struggling to convert its results into something that allows me to insert the required number of dummy columns and set the final column in a reasonably elegant way.
Any suggestions, please?