November 12, 2013 at 1:37 pm
I have a inbound, pipe delimited, file. The first and last records contain audit information pertaining to the file. I want to extract these out and throw them into a table. The number of columns varies between the header, body, and trailer columns, but are a fixed amount between the three. 5, 71, 6. Any advice on how I can split this up?
Any help would be appreciated.
November 12, 2013 at 2:18 pm
In PowerShell 3.0 and higher you could use the following:
Test.txt
First
something
something else
Last
$filename = 'C:\work\test.txt'
Get-Content $filename -Head 1
Get-Content $filename -Tail 1
November 12, 2013 at 2:39 pm
I haven't used much PowerShell, but I appreciate the input. I'll check this out.
November 13, 2013 at 7:08 am
You don't need powershell if you don't want it.
An article in doing this in SSIS with scripts:
http://www.blue-chip.com.au/ssis-file-with-header-detail-trailer.aspx
Basically reads the file as non delimited and parses it in a script task.
November 15, 2013 at 2:26 am
Nevyn (11/13/2013)
You don't need powershell if you don't want it.An article in doing this in SSIS with scripts:
http://www.blue-chip.com.au/ssis-file-with-header-detail-trailer.aspx
Basically reads the file as non delimited and parses it in a script task.
It's actually a script component rather than a script task.
Other than that, it looks like a good reference. As long as you do not need the information in the final row before you read the data rows.
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply