I am aiming to read a csv file in my c# method. this csv file is not defined and it can have n number of columns. One thing which will always remain constant is that there will be only two rows in csv file. one will be header row and other will be value row. My below method works fine when my values are string values but fails when one of my value is something like this [test,test1,test2]. I tried with Csv helper class but I am unable to do. can someone suggest me how should I approach?
metadata is list of lines I read from StreamReaderprivate void AddValuesToTable( DynamicTableEntity tableEntry, List<string> metadata )
{
var headers = metadata[0].Split( "," );
var values = metadata[1].Split( "," );
for( int i = 0; i < headers.Count(); i++ )
{
tableEntry.Properties.Add( headers[i].ToString(), EntityProperty.CreateEntityPropertyFromObject( values[i] ) );
}
}
Sample value:
columnA,columnB,columnC
valA,[testa,testb],valc
metadata[1]?[and]are allowed inside the value? If so, how do you escape them to differentiate from the ones used for field quotation?