I was trying to add the strings to the List and export the list as csv file but the result I got is not the way I want. Here is the code -
List<string> values = new List<string>();
using (StreamReader sr = new StreamReader(filePath))
{
while (sr.Peek() != -1)
{
string line = sr.ReadLine();
List<string> lineValues = line.Split(',').ToList();
var tempMinInt = 1;
var tempValue = 1;
var tempValInt = Convert.ToInt32(lineValues[4]);
if (tempValInt % 60 != 0)
{
tempMinInt = (tempValInt / 60) + 1;
tempValue = tempMinInt * 30;
}
else
{
tempMinInt = tempValInt / 60;
tempValue = tempMinInt * 30;
}
values.Add(lineValues + "," + tempValue.ToString());
}
}
Here is the sample input data:
33083,2011-12-19 05:17:57+06:30,98590149,1876,258
33084,2011-12-19 05:22:28+06:30,98590149,1876,69
33085,2011-12-19 05:23:45+06:30,98590149,1876,151
33086,2011-12-19 05:30:21+06:30,98590149,1876,58
33087,2011-12-19 06:44:19+06:30,949826259,1876,66
And here is the output data:
System.Collections.Generic.List`1[System.String],150
System.Collections.Generic.List`1[System.String],60
System.Collections.Generic.List`1[System.String],90
System.Collections.Generic.List`1[System.String],30
System.Collections.Generic.List`1[System.String],60
Please advice. Thank you.