SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


CSV file to table


CSV file to table

Author
Message
rs80
rs80
Mr or Mrs. 500
Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)

Group: General Forum Members
Points: 518 Visits: 409
I'm wondering if the data from a sample csv file can be transformed and loaded into a table. I have attached a workbook where worksheet1 has the sample data and worksheet2 has how the data should look in the table.

Thanks for the help!
Attachments
SampleData.xlsx (26 views, 9.00 KB)
Sean Lange
Sean Lange
SSC Guru
SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)

Group: General Forum Members
Points: 63935 Visits: 17974
rs80 (4/4/2014)
I'm wondering if the data from a sample csv file can be transformed and loaded into a table. I have attached a workbook where worksheet1 has the sample data and worksheet2 has how the data should look in the table.

Thanks for the help!


I didn't look at your excel document but this is pretty simple to do. You can right click the database and import if this is a one time thing. If it is something you need to do repeatedly then look into creating an SSIS package to do this.

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Modens splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
rs80
rs80
Mr or Mrs. 500
Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)

Group: General Forum Members
Points: 518 Visits: 409
Thanks Sean for your reply. The loading of the file is on a daily basis. The layout of the data isn't straightforward so it's difficult for me to figure out how to store it in the table. Please take a look at the file.
Sean Lange
Sean Lange
SSC Guru
SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)

Group: General Forum Members
Points: 63935 Visits: 17974
rs80 (4/4/2014)
Thanks Sean for your reply. The loading of the file is on a daily basis. The layout of the data isn't straightforward so it's difficult for me to figure out how to store it in the table. Please take a look at the file.


I am not by any stretch of the imagination good with SSIS but this doesn't look that bad. Have you tried working with it to see if you can get it even close?

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Modens splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
rs80
rs80
Mr or Mrs. 500
Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)

Group: General Forum Members
Points: 518 Visits: 409
I usually use a flatfile source for csv files. But since this csv has a different layout because of the way the headers are repeated I wasn't sure what to do.

My co-worker ended up loading the data into a staging table and parsing the data using a SP to a final table.

However, I was wondering if there is a way to do this in SSIS. I would imagine I'd have to use a script component to do some preprocessing. But that's why I thought of asking the experts to see what they think.
Sean Lange
Sean Lange
SSC Guru
SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)

Group: General Forum Members
Points: 63935 Visits: 17974
rs80 (4/4/2014)
I usually a flatfile source for csv files. But since this csv has a different layout because of the way the headers are repeated I wasn't sure what to do.

My co-worker ended up using loading the data into a staging table and parsing the data using a SP to a final table.

However, I was wondering if there is a way to do this in SSIS. I would imagine I'd have to use a script component to do some preprocessing. But that's why I thought of asking the experts to see what they think.


Loading to a staging table is the best way to go. Sounds like you figured it out. COOL!!!

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Modens splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
rs80
rs80
Mr or Mrs. 500
Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)

Group: General Forum Members
Points: 518 Visits: 409
Does anyone else have any other suggestions?
herladygeekedness
herladygeekedness
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1368 Visits: 813
I wouldn't quite call your source a csv file!!! This is not formatted in a consumable manner.

Whomsoever it is that generates this file should provide an actual data file. SSIS can't do anything with this.

You are better off using vba to parse the Excel into an actual csv but methinks this is not the only manner in which this file will show up so I am guessing there is no repeatable process you can write until they standardize the source data into an actual Data File.

Good luck!
rs80
rs80
Mr or Mrs. 500
Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)Mr or Mrs. 500 (518 reputation)

Group: General Forum Members
Points: 518 Visits: 409
Thanks methinks.
herladygeekedness
herladygeekedness
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1368 Visits: 813
Please let us know how it goes. I have often had a user adamant that what they provide is "good enough" so if you meet with resistance and really have to work with that file as is, come on back here.

I strongly hope they have the desire to create a real data file for you as it will be smooth sailing for you after that.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search