I’m using toCsv() to serialize a list that is imported into MySQL using the “load data local infile” command
C#
var hlist = new List<>();
System.IO.File.WriteAllText($“/tmp/page-{p}.csv”,hlist.ToCsv());
In MySQL
load data local infile ‘/tmp/page-0.csv’
into table LocalSyncHeaders
enclosed by ’ " ’
FIELDS TERMINATED BY ‘,’
LINES TERMINATED BY ‘\n’;
The problems are:
1 - the field titles get inserted into the db as the first row
2 - it expects fields to be enclosed in double-quotes and without it stops importing
Clearly I can control some of this in MySQL.
Question:
1 - Is there any way to control ToCsv() so it can better match what MySQL expects.
2 - I see that there is an option for
ServiceStack.Text.CsvConfig.CustomHeadersMap
are there any other control points for csv serialization?