Padding a Text File

Oct 1 2003 11:02 PM
I am new to C#, so don't laugh! :-) I have an issue that I have not been able to find a solution for and have searched and read for 3 weeks. Here is my dilema: I have a text file that contains 400,000 rows. Each row begins with a 3 character text identifier. (I can email a sample file) This text identifier or (Record Type) can be one of 11 different values and starts every row. The rest of the row contains additional data that is supposed to be in Fixed Length. I've created a SQL Server DTS package to import from this file and break it down into 11 different tables based on Record Type (I used a simple Active X script to filter the data). Also the file second column (positions 3 - 13) is a unique Identifier and ties all Record Types together that should be connected, such as additional address info and such. The rows in the file aren't all the same length. So when you check the tables after import they are missing rows. If you were to compare the file to the table, looking at the unique identifier, then you would see that the text file starts at 2 and the table starts at 31 and skips throughout. So I figured a program in C# would be able to take the text file and pad the shorter rows, which will fix my problem. However, I can't figure it out! Any help would be very appreciated! I hope this wasn't too long and boring, but I didn't know what would be needed for a good understanding of the issue. P.S the file layout would be different for the 11 Record Types.

Answers (3)