Last post Sep 24, 2015 12:49 PM by RDowdall
Sep 24, 2015 12:42 PM|RDowdall|LINK
I needed to perform some filtering on large delimited files. I loaded the files into a sql table, performed the data manipulation and then exported the files as | delimited. The original files had field separators as delimiters which in C# are (char)(28).
The delimiters appear as FS in Notepad++. Now I am trying to convert the pipe back to the Field Separators but have not been able to find the equivalent in a char format. I tried line.Replace as show in the code below, but I end up with the pipes anyway.
Can anyone help?
Char c = new Char();c=(char)(28); //Field Separatorstring line="";using (StreamReader inputBundleFile = new StreamReader(@"c:\RKISET\PU401650922_New.RKI"))
while ((line = inputBundleFile.ReadLine()) != null)
using (StreamWriter outfile = new StreamWriter(@"c:\RKISET1\PU401650922_New.RKI"))
Sep 24, 2015 12:45 PM|Rion Williams|LINK
It's important to remember that the Replace() method doesn't work inline, it actually returns a string with the replacement already performed, so you need to update your line as such :
line = line.Replace("|", c);
Sep 24, 2015 12:49 PM|RDowdall|LINK
Somebody needs to slap me on the back of the head.
Thanks, that did it.