1

I hope someone can help me with this.

I have a text file with 3 columns, the first column is always a name, the second one a name/name+number and the 3th column is a timestamp (hour,min,sec,ms).

The text file looks like this:

Jake,Start,16:12:49.382
Chris,Start,16:12:50.111
Jake,Loop1,16:12:56.175
Chris,Loop1,16:13:00.943
Chris,Loop2,16:13:08.100
Jake,Loop2,16:13:08.442

In this example there are two people cycling (Jake and Chris), but this could be a maximum of six people. So a maximum of 18 lines (Start, Loop1, Loop2 for each cyclist). For each cyclist I want to calculate the Splittimes and then store this data in a new variable (RiderOne=Jake, RiderTwo=Chris, RiderThree=..etcetera). The splittimes are calculated like this:

Splittime1(Jake)=TimeStampLoop1 - TimeStampStart [16:12:56.175 -16:12:49.382=6,793s]
Splittime2(Jake)=TimeStampLoop2 - TimeStampLoop1 [16:13:08.442 -16:12:56.175 =12,267s]

The output should look somewhat like this:

String RiderOne =
 Jake
Splittime1:
 6,793 s
Splittime2:
12,267 s
String RiderTwo =
Chris
Splittime1:
10,832 s 
Splittime2:
 7,157 s
String RiderThree =
etc..

Every bit of help to get me started is very much appreciated. I did a lot of research but I can't seem to find a similar example, so I'm a bit lost. ps. I can also use CSV instead of TXT if that is easier.

skink
  • 5,133
  • 6
  • 37
  • 58
Boike
  • 11
  • 1
  • 2
    Take a look at File.ReadAllLines(), string.split(), DateTime.Parse() and Console.WriteLine(). – Markus Deibel Oct 26 '17 at 08:34
  • If thats the format of your file, then you just need to treat it as a CSV and parse it into object format (will make life alot easier for you than reading the lines individually) Check out https://stackoverflow.com/questions/3497699/csv-to-object-model-mapping – Takarii Oct 26 '17 at 08:39
  • Also, is there a reason why you can't keep data for one person on the same line? eg start, loop1, loop2 – Takarii Oct 26 '17 at 08:45
  • @Takarii yes unfortunately I cannot change how the data is saved in the text/csv file. I am trying the object format at the moment. – Boike Oct 26 '17 at 08:59

0 Answers0