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


Preprocessing Flat Files


Preprocessing Flat Files

Author
Message
Gabriel P
Gabriel P
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1142 Visits: 947
Question for you guys - what have you found as the best way to preprocess flat txt files to prepare them for SSIS? For example say the 3rd party vendor has issues with their files that don't follow the specifications, but it's to a point where it so common that you have an automated fix for it. However they are formating issues that break the SSIS Flat File Source object.

Examples: End of line format changing (CR vs CRLF), "NULL" appearing in numeric columns, delimiters changing (e.g. normally a pipe, but occasionally appear as commas instead).

The obvious solution for me was to write some C# to do preprocessing, but at that point you might as well do the whole thing in C# as it's inefficient to read the whole file in memory to prevalidate, then re-read it again to load it.
EricEyster
EricEyster
Right there with Babe
Right there with Babe (770 reputation)Right there with Babe (770 reputation)Right there with Babe (770 reputation)Right there with Babe (770 reputation)Right there with Babe (770 reputation)Right there with Babe (770 reputation)Right there with Babe (770 reputation)Right there with Babe (770 reputation)

Group: General Forum Members
Points: 770 Visits: 520
sometimes this comes down to being able to maintain the code in the future, as it sounds like your will be finding new issues as time goes on. If you are familiar with .Net code, then add the fixes into a script task before the data flow task. Yes, you could load the data with the SqlBulkLoad objects and get the same speed as SSIS, but will the next guy easily understand the code?
Gosta Munktell
Gosta Munktell
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1537 Visits: 2161
"Examples: End of line format changing (CR vs CRLF), "NULL" appearing in numeric columns, delimiters changing (e.g. normally a pipe, but occasionally appear as commas instead)." If with Changes within the same file you are in a problem.

One possible solution is may to use bulk insert into a staging table with one column varchar(max).
In that cloumn you can test for certain conditions for each row in the text file with SQL statements
and then split the row into the apropriate number of columns and insert in a useable table.
I use this typ of procedeure then I import text files.

Best regards
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