Solved

SSIS Importing CSV file

Posted on 2010-08-25
4
993 Views
Last Modified: 2013-11-10
I have set up a Flat File Source in SSIS to load in a CSV file. The trouble that I am having is that some rows have 10 columns, some have 15. When I set up the column structure, the first row had 10 columns, so I added the missing columns to the data structure, but when I do that, it does not appear to be picking up the CR/LF characters, so in the column that I create, it looks like its pulling in the CR/LF control characters followed by the first value of the new line and so on.

I've tried all the variations of the row delimiter, but nothing seems to work as the line feed and properly load the new line of data.

Could it be that the csv source file has an unknown CR/LF character or am I not setting up the parameters of the file connection properly?
0
Comment
Question by:wppiexperts
  • 2
  • 2
4 Comments
 
LVL 16

Accepted Solution

by:
vdr1620 earned 50 total points
Comment Utility
it might be possible that when you added the extra columns the CR/LF on that line might have been messed up..if you added all the extra columns needed ..i would say, open the CSV file in Excel format and then add an extra blank column to the end (using insert column to right in excel).. Doing that, will add an extra column to the end with correct CR/LF.. In SSIS, Source just select the columns that you need..

If this is a recurring process where the file has In Variable columns.i would suggest you to take a dynamic approach by using script task where you can split the data as suggested in link below , so that you don't have to do any changes to the file manually

http://agilebi.com/cs/blogs/jwelch/archive/2007/05/08/handling-flat-files-with-varying-numbers-of-columns.aspx
0
 

Author Comment

by:wppiexperts
Comment Utility
as an additional note, I threw together a sample file with 3 columns and a couple rows of data, the import worked fine. However, when one of the rows only had 2 columns, the import went haywire and didn't load properly. So it looks like when using the flat file connection manager, each row of data has to be uniform, otherwise this issue will arise.
0
 
LVL 16

Expert Comment

by:vdr1620
Comment Utility
Yes the issue will definitely arise.. Thats the reason i suggested you to take a dynamic approach as suggested in the link where you treat the row as one complete column and then in the script you split the columns. please check the link above
0
 

Author Closing Comment

by:wppiexperts
Comment Utility
wow - you link was the perfect solution! Thanks!
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now