I have a tab separated text file which is about 1.2 GB , i need to convert it into CSV file(Comma Separated) using c#. I have to insert a bulk data into sqlserver, the data is i
I came up with this which splits on the tab character:
using(System.IO.StreamReader rdr = new System.IO.StreamReader(@"C:\text.txt"))
{
int counter = 0;
string lne;
while((lne = rdr.ReadLine()) != null)
{
string[] temp = lne.Split('\t');
Console.WriteLine(temp[0]);
Console.WriteLine(temp[1]);
counter++;
}
}
Console.ReadLine();
After that you can just use a StringBuilder to concatenate the the items in the array with a comma.