within my Csv File i have a column which holds a string and a datetime type. i would like to separate these data in two columns, one column which holds the string and one which holds the date but converts the datetime type as a string too.
After doing some research i noticed that i could use the string.split function which will add a comma after the three character which are TIP and then push the date in a new column. however i do not know to code this process
class Program
{
static void Main(string[] args)
{
string currentDirectory = Directory.GetCurrentDirectory();
DirectoryInfo directory = new DirectoryInfo(currentDirectory);
var fileName = Path.Combine(directory.FullName, "Climate 02_08_2016.csv");
var fileContents = ReadFile(fileName);
string[] fileLines = fileContents.Split(new char[] { 'r', 'n' }, StringSplitOptions.RemoveEmptyEntries);
foreach (var line in fileLines)
{
Console.WriteLine(line);
}
}
public static string ReadFile(string fileName)
{
var column5 = new List<string>();
using (var reader = new StreamReader(fileName))
{
while (reader.EndOfStream)
{
var splits = reader.ReadLine().Split(';');
column5.Add(splits[4]);
}
return reader.ReadToEnd();
}
}
}