This repository was archived by the owner on Dec 24, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -59,7 +59,8 @@ public static List<string> ParseLines(string csv)
5959 return rows ;
6060 }
6161
62- public static List < string > ParseFields ( string line )
62+ public static List < string > ParseFields ( string line ) => ParseFields ( line , null ) ;
63+ public static List < string > ParseFields ( string line , Func < string , string > parseFn )
6364 {
6465 var to = new List < string > ( ) ;
6566 if ( string . IsNullOrEmpty ( line ) )
@@ -70,7 +71,7 @@ public static List<string> ParseFields(string line)
7071 while ( ++ i <= len )
7172 {
7273 var value = EatValue ( line , ref i ) ;
73- to . Add ( value . FromCsvField ( ) ) ;
74+ to . Add ( parseFn != null ? parseFn ( value . FromCsvField ( ) ) : value . FromCsvField ( ) ) ;
7475 }
7576
7677 return to ;
@@ -355,7 +356,9 @@ public static List<T> Read(List<string> rows)
355356
356357 List < string > headers = null ;
357358 if ( ! CsvConfig < T > . OmitHeaders || Headers . Count == 0 )
358- headers = CsvReader . ParseFields ( rows [ 0 ] ) ;
359+ {
360+ headers = CsvReader . ParseFields ( rows [ 0 ] , s => s . Trim ( ) ) ;
361+ }
359362
360363 if ( typeof ( T ) . IsValueType || typeof ( T ) == typeof ( string ) )
361364 {
You can’t perform that action at this time.
0 commit comments