Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
543 views
in Technique[技术] by (71.8m points)

ssis - How to read a flatfile with lowercase thorn as the delimiter

I'm trying to read a flat file in SSIS which is in this format

col1 t col2 t col 3

I'm using the flatfile connection manager but there is no option for the 't' character in the column delimiter section of the connection manager.

What would be the workaround for this? Other than reading the file and replacing the thorn character with a SSIS supported delimiter,

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Being a dumb 'merican, I think the lower case thorn character is 0xFE while upper case is 0xDE. This will become important soon.

I created an SSIS package with a Flat File Connection Manager. I pointed it at a comma delimited file that looked like

col 1,col 2,col 3

This allowed me to get the metadata set for the file. Once I have all the columns defined and my package is otherwise good. Save it. Commit it to your version control system. If you're not using version control, shame on you, but then make a copy of your .dtsx file and put it somewhere handy.

Replace the comma delimited file with the a thorn delimited one.

What we're doing

What we're going to do is edit the XML that is our SSIS package by hand to exchange the delimter of a , with a t. It's a straight forward operation but since you are going off the reservation, it's easy to foul up and then your package won't open up properly in the editor.

How to fix it

If you have the package open, close the package but leave Visual Studio open. Right click on the file and select "View Code".

In an SSIS 2012 package, you'll be looking for

DTS:ColumnDelimiter="_x002C_"

In a 2008 package,

<DTS:Property DTS:Name="ColumnDelimiter" xml:space="preserve">_x002C_</DTS:Property>

What we're going to do is substitute _x00FE_ (thorn) for _x002C_ (comma). Save the file and then double click to open it back up.

Your connection manager should now show the thorn symbol on the Columns tab.

enter image description here

Interestingly enough, after you open the package, if you go back into the Code, the editor will have swapped the thorn character into the file in place of the hexagonal character code. Weird.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...