hellow
i need a piece of code thatvconvert a tab delimited txt file to comma delimited along with each column enclosed in ' '
for example i ahve a txt file and the format is ----> abc efg 123
i need to convert it like --> 'abc','efg','123'
thanks in advance
faraz akram
JeffPosted Feb 3, 2009, 1:32 AM
I assume you can read in the file, one row at a time. Then just pass each row to a function like this, which replaces each instance of "single-quote comma" with "single-quote tab" and returns a new string. Bear in mind the data in individual fields of your data document might have commas and/or single-quotes. If so, you might need a different pattern for your regex.
private static string ReplaceCommas(string rowData)
{
string pattern = "',";
string revisedRowData = Regex.Replace(rowData, pattern, "'\t");
return revisedRowData;
}