JoshClose / CsvHelper

Library to help reading and writing CSV files
http://joshclose.github.io/CsvHelper/
Other
4.65k stars 1.05k forks source link

Access to the raw line #2201

Closed LiorBanai closed 9 months ago

LiorBanai commented 9 months ago

I would like to have access to the raw parsed line in addition to the parsed fields. This will help me sicne I also need the raw text for ech line to process separately.

Rob-Hague commented 9 months ago

You can use csvReader.Parser.RawRecord

LiorBanai commented 9 months ago

@Rob-Hague great. thanks!

btw can I replace the separator character? in my csv I have | as separator and not ,

Rob-Hague commented 9 months ago

Yes you can do something like


var config = new CsvConfiguration(CultureInfo.InvariantCulture)
{
    Delimiter = "|"
};

using var csvReader = new CsvReader(textReader, config);

See https://joshclose.github.io/CsvHelper/ (or the unit tests in the repo) for more documentation/examples

LiorBanai commented 9 months ago

Great. Thanks again!