SSIS - 如何仅使用 1 个文本限定符导入 csv

发布于 2025-01-18 22:04:34 字数 479 浏览 3 评论 0原文

我正在使用SSIS并尝试导入CSV文件。但是,只有1个字段具有文本限定词 - 双引号“ - 又包含逗号。即使我指定了“作为限定符,SSIS似乎也忽略了这一点,并且仍然将数据分配到下一个字段中 - 是否有一个解决方案还是所有列都需要预选赛才能工作?

这是数据的一个示例:

Field1,    Field2,    Field3,       Field4
ABC,        123,       "QWER,ASD",  ZXC

因此,当我目前导入时,SSIS正在分裂field3,即使我指定了“作为文本预选赛 - 为什么?

我这样?

I'm using SSIS and trying to import a csv file. However, only 1 field has a text qualifier - double quotes " - which in turn also contains commas. Even if I specify the " as a qualifier, SSIS seems to ignore this and still splits the data into the next field - is there a solution or do all columns need the qualifier for it to work?

This is an example of the data:

Field1,    Field2,    Field3,       Field4
ABC,        123,       "QWER,ASD",  ZXC

So when I import at the moment, SSIS is splitting Field3, even though I have specified " as a text qualifier - why is this?

I am defining the text qualifier thus:
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

林空鹿饮溪 2025-01-25 22:04:34

问题是您的文件,已畸形。您在值之前具有前导空间(123),并且行中的列不匹配;标题有5列和数据行4列。为了使一个值正确的文本合格,资格符必须位于值的开始
“ qwer,asd”正确
“ qwer,asd”不正确

您首先修复文件。大概您不想要领先的空间,所以看起来像这样:

Field1,Field2,Field3,Field4
ABC,123,"QWER,ASD",ZXC

然后SSIS按照您的期望工作:

如果您 do 想要领先的空格(在值和列名中),则应该像这样:

Field1,    Field2,    Field3,       Field4
ABC,        123,"       QWER,ASD",  ZXC

它也可以按照您的“期望”:

The problem is your file, it's malformed. You have leading spaces prior to your values (123) and a mismatch of columns in your rows; the header has 5 columns and the data row 4 columns. For a value to be correctly text qualified the qualifier must be at the start of the value:
" QWER,ASD" Correct
"QWER,ASD" Incorrect

You need to fix your file first. Presumably you don't want the leading spaces, so it should look like this:

Field1,Field2,Field3,Field4
ABC,123,"QWER,ASD",ZXC

Then SSIS works as you expect it to:
enter image description here
enter image description here

If you do want the leading spaces (in the values and column names) it should look like this:

Field1,    Field2,    Field3,       Field4
ABC,        123,"       QWER,ASD",  ZXC

Which also works as you would "expect":
enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文