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)
59
59
return rows ;
60
60
}
61
61
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 )
63
64
{
64
65
var to = new List < string > ( ) ;
65
66
if ( string . IsNullOrEmpty ( line ) )
@@ -70,7 +71,7 @@ public static List<string> ParseFields(string line)
70
71
while ( ++ i <= len )
71
72
{
72
73
var value = EatValue ( line , ref i ) ;
73
- to . Add ( value . FromCsvField ( ) ) ;
74
+ to . Add ( parseFn != null ? parseFn ( value . FromCsvField ( ) ) : value . FromCsvField ( ) ) ;
74
75
}
75
76
76
77
return to ;
@@ -355,7 +356,9 @@ public static List<T> Read(List<string> rows)
355
356
356
357
List < string > headers = null ;
357
358
if ( ! CsvConfig < T > . OmitHeaders || Headers . Count == 0 )
358
- headers = CsvReader . ParseFields ( rows [ 0 ] ) ;
359
+ {
360
+ headers = CsvReader . ParseFields ( rows [ 0 ] , s => s . Trim ( ) ) ;
361
+ }
359
362
360
363
if ( typeof ( T ) . IsValueType || typeof ( T ) == typeof ( string ) )
361
364
{
You can’t perform that action at this time.
0 commit comments