From 8df9cac185c49d3fa452cf7666a18c1cb137bbcd Mon Sep 17 00:00:00 2001 From: "joshua.b" Date: Tue, 14 Mar 2023 17:58:38 -0700 Subject: [PATCH] Added the option to make header parsing case-sensitive. --- code/LumenWorks.Framework.IO/Csv/CsvReader.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/code/LumenWorks.Framework.IO/Csv/CsvReader.cs b/code/LumenWorks.Framework.IO/Csv/CsvReader.cs index bbe8ff9..1d2ac9e 100644 --- a/code/LumenWorks.Framework.IO/Csv/CsvReader.cs +++ b/code/LumenWorks.Framework.IO/Csv/CsvReader.cs @@ -1418,9 +1418,12 @@ public bool ReadNextRecord() /// Indicates if the reader will skip directly to the next line without parsing the current one. /// To be used when an error occurs. /// + /// + /// Indicates if the reader should be case-sensitive when parsing headers. + /// /// if a record has been successfully reads; otherwise, . /// The instance has been disposed of. - protected virtual bool ReadNextRecord(bool onlyReadHeaders, bool skipToNextLine) + protected virtual bool ReadNextRecord(bool onlyReadHeaders, bool skipToNextLine, bool caseSensitiveHeaders = false) { if (_eof) { @@ -1488,7 +1491,8 @@ protected virtual bool ReadNextRecord(bool onlyReadHeaders, bool skipToNextLine) Array.Resize(ref _fields, _fieldCount); } - _fieldHeaderIndexes = new Dictionary(_fieldCount, StringComparer.CurrentCultureIgnoreCase); + var headerComparer = caseSensitiveHeaders ? StringComparer.CurrentCulture : StringComparer.CurrentCultureIgnoreCase; + _fieldHeaderIndexes = new Dictionary(_fieldCount, headerComparer); _initialized = true;