I have a csv file I am reading from
Din, Anh , 69
James, Urbank,61
I want to add another name " Ernest , Cuban , 70 " to the csv string , so I first delimited each values with the comma. I started looking for an insert function and found one so I added this line to my code
|>Seq.map (fun values ->
values.[0].Insert(0,"Ernest")),
values.[1].Insert(0,"Cuban")),
float values.[2].Insert(0,"70"))
Obviously that didn't work what ends up happening is the Ernest is added to the beginning of Din and James , Cuban to the beginning of Anh and Urbank , and 70 to the beginning of 69 and 61.
ErnestDin , CubanAnh , 7061
So my question is how can I add those values to my seq , keeping in mind that Ernest would be in the middle of both Din and James as the sequence has to be in alphabetical order . I researched and found the Map.add that gave me an alphanumerical number as a result and the Seq.Append seems to only be working with integers.
Sequences in F# are immutable, so you can't just insert data into them. If your data set isn't too big, the easiest solution may simply be to add the new data to the head of a list, and then sort it:
Note that this most likely isn't the most efficient solution, but it's Easy :)