I am using the excellent CsvHelper libary. Now I need to explicitly add some leading and trailing spaces to a field. I do this using:
private const string Space = " ";
//....
Map(x => x.Bandwidth).Index(++indexCounter).ConvertUsing(item => Space + item + Space).Name("Bandwidth");
This works, as long as I do not choose to generally trim using
// Default value
csv.Configuration.TrimFields = true;
as described in the CsvHelper docs. But how can I generally use trimming, excpet for a specific field? I am using version 2.5.0 at the moment.
Is there a way to omit trimming for one field only?
Edit:
I just found out that my approach using ConvertUsing
is completely broken: See CsvHelper ConvertUsing not changing output I'm going to either delete or update this question later.