Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Carat
Yak Posting Veteran
92 Posts |
Posted - 2009-08-25 : 10:37:40
|
I need to import a CSV file that has 6 header rows. I need these 6 header rows to do some calculations and I also need all the data rows. How can I best accomplish this?This is an example of my CSV file:Text file created on 03.08.2009;13:34:20file name=prod\qledSignature=1.162.424.863Generation=58.458Last qlDateTime=31.07.2009;23:59:50Inception=01.09.2007;23:59:58column1;column2;column3,...252.1;I;P,...252.1;I;P,...252.1;I;P,...The only way I can think off to make this work is to set a Flat File Source and skip the first 6 records and capture this source in a table. And then set another Flat File Source and only capture the first column in another table.Am I right or is there another way?Is there a way to capture the first 6 rows in an variable or something?Thanks. |
|
YellowBug
Aged Yak Warrior
616 Posts |
Posted - 2009-08-25 : 11:31:09
|
That's right. Create two connections to the same file - as the format changes.The header source can be directed into variables using the Script component.In the data source specify the "Header rows to skip" to be 6.You can also use the Conditional Split transformation to direct rows in a dataset. |
 |
|
Carat
Yak Posting Veteran
92 Posts |
Posted - 2009-08-26 : 05:53:28
|
Thank you for your answer.I created 2 connections and it works fine. But the problem now is that my first connection, that captures the first 6 header rows, is going to import all the records in a table while I only need the first 6. Is there a way to import only the first 6 header rows in my table and to skip the rest of the data rows? |
 |
|
YellowBug
Aged Yak Warrior
616 Posts |
Posted - 2009-08-26 : 06:13:45
|
You can import only the first 6 rows using the "Bulk Insert Task".And specify the LastRow to be 6. |
 |
|
Carat
Yak Posting Veteran
92 Posts |
Posted - 2009-08-26 : 08:37:33
|
Ok thanks! |
 |
|
|
|
|