Comma within fields in CSV file -import to DB using SSIS

只谈情不闲聊 提交于 2019-12-01 00:35:18

问题


I have a CSV file - It has many values having comma as a part of value.The commas within the fields will mislead my SSIS package to understand that file row has more columns than previously said!

How to resolve this?

Eg:

Name,Amount,Address

Me,20,000,My Home,India

you,23,300,Your Home,Where

here only 3 columns exist but SSIS assumes all commas used to separate fields;Actually not all.Amount Column and Address Column have extra commas.


回答1:


Use Text Qualifier in Flat file Connection Manager as ". This will separate only values out of quotes by commas. Your data from db will be enclosed in quotes.




回答2:


You will need to ensure that all values in the file that have commas as part of the text are enclosed in double quotes ("). Then you can set the text qualifier in your flat file source, and the commas will be loaded as part of the string fields.




回答3:


I feel that a better way of doing this is by using a Derived column Transformation Editor in SSIS Data Flow, and changing the expression to surround the string with double quotes.

For instance if the column "Address" has records with commas, then create an expression such as

"\""+Address+"\""

in the Derived Column Transformation Editor.

I think this is a good option if you are not willing to transform the source.



来源:https://stackoverflow.com/questions/23289514/comma-within-fields-in-csv-file-import-to-db-using-ssis

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!