0

I have a file written from a Cobalt program that produces a pipe delimeted file. The file contains white space and "null" spaces that I need to get rid of and then rewrite the file. What is the best way to do that? I have sql server and visual studio that can be used to write the script, but not sure the best one to use or exactly how. The script will need to read through many different files in a folder. The data is being converted from an old system into a new one. Also, I would need to keep spaces between words, ie a business name or an address. I was going to use sql, but can only find examples reading fields in a database.

Example file (one line): 0000000009|LName |FName | | | | | | |1|1|0|000|000|000000000| 1||null null null| | null null|null null null null| |1|0|

Desired output: 0000000009|LName|Fname|||||||1|1|0|000|000|000000000|1||||||1|0|

Thanks!!

4

1 回答 1

1

You said you can use visual studio, so this example uses c#.

I suppose you will load your file content into a string, then you can apply some replaces:

s.Replace("null", string.Empty).Replace(" |", "|").Replace("| ", "|").Replace("| |", "||");

I know there are probably a lot of much more elegant solution: this is quick and dirty but it will output the string you need.

Hope this helps.

于 2013-10-04T15:13:11.200 回答