![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Each day I download perhaps 20 text files from a mainframe. I wrote an ASP script that opens the files, reads the contents, and extracts data to be imported into SQL Server. There's not a huge amount of data in those files, perhaps 500 kb daily, but the process takes some time. I'm looking for ways to make it more efficient. DTS allows efficient importing of fixed-width text files. But I'm not sure how to use it with the files I download. Instead of having the usual one-row-one-record format, these have up to three rows per record. Each row has a "header," if you will, that specifies what's to follow. For example, a file might look like this: Dog1Spot0000 Dog2Mastiff0 Dog3Purebred My script goes through the file line by line, extracts the dog's name from row 1, the breed from row 2, and pedigree from row 3, and finally constructs the SQL statement. I'd sure love to be able to grab a chunk of data using DTS and just plunk it into SQL Server. Any ideas of how to do this? --Brent |
#3
| |||
| |||
|
|
Each day I download perhaps 20 text files from a mainframe. I wrote an ASP script that opens the files, reads the contents, and extracts data to be imported into SQL Server. There's not a huge amount of data in those files, perhaps 500 kb daily, but the process takes some time. I'm looking for ways to make it more efficient. DTS allows efficient importing of fixed-width text files. But I'm not sure how to use it with the files I download. Instead of having the usual one-row-one-record format, these have up to three rows per record. Each row has a "header," if you will, that specifies what's to follow. For example, a file might look like this: Dog1Spot0000 Dog2Mastiff0 Dog3Purebred My script goes through the file line by line, extracts the dog's name from row 1, the breed from row 2, and pedigree from row 3, and finally constructs the SQL statement. I'd sure love to be able to grab a chunk of data using DTS and just plunk it into SQL Server. Any ideas of how to do this? --Brent |
#4
| |||
| |||
|
#5
| |||
| |||
|
|
Thanks for your tips. Specifying the total length of the data, including the control returns, seems to work, except that I have run into another snag that I forgot about when describing the data structure. Each text file comes with additional header trailer lines. The resulting file looks something like this: Head01Westminster Dog1Spot0000 Dog2Mastiff0 Dog3Purebred Dog1Buddy000 Dog2Corgi000 Dog3Purebred Trail8lines I would need DTS -- or something -- to strip out the first and last lines. I guess I could write a script to do this, and then pass control over to DTS, but is there any easier way? Thanks again! --Brent |
![]() |
| Thread Tools | |
| Display Modes | |
| |