I have an F# Library I call from C# that reads JSON output and CSV files. The library does processing of the data.
When reading a CSV file to a datatable, I can iterate over the header row like this:
let myfile=FSharp.Data.CsvFile.Load(inFile)
let headers=[| myfile.Headers.Value |]
headers.[0]
|>Seq.iter(fun y-> dataTable.Columns.Add(new DataColumn(y)))
What I want to do is pass in a pipe-delimited string as a parameter(hdrString) from C# in the event the file does not contain a header. e.g. "Col1|Col2|Col3". I was intending to use match to determine if the string was empty then revert to the file headers by splitting the string. I can't, however, seem to split the string (hdrString.split [ '|' ]) successfully into an string array (string[] []). I've tried split but it gives me an error, essentially, that I can't convert string to obj. I also tried hdrString.ToCharArray() but char[] is not compatible with string[]. Any suggestions on how I can do this?
String.Split. You should add the errors you got from that.