SSIS 2012: Trim trailing commas from a CSV output(SSIS 2012:从 CSV 输出中修剪尾随逗号)
问题描述
我有一个文件,我无法控制输出,它在每个数据行而不是标题行上都有一个尾随逗号.
I have a file, I cannot control the output, that has a trailing comma on each data row and not the header row.
"Pid","Dtdate","Tencode","Stype","Amount","Currentbal"
"13773793","05/26/2014","Abc123","PAYMENT","50.00","1807.95",
"13773794","05/26/2014","Abc123","ADJUSTMENT","10.00","18.95",
"",
我想弄清楚如何修剪尾随逗号的每一行,以便它在 SSIS 中正确读取.
I am trying to figure out how to trim each row of the trailing comma so that it will read in SSIS correctly.
"Pid","Dtdate","Tencode","Stype","Amount","Currentbal"
"13773793","05/26/2014","Abc123","PAYMENT","50.00","1807.95"
"13773794","05/26/2014","Abc123","ADJUSTMENT","10.00","18.95"
""
我假设我会使用脚本转换,但这就是我卡住的地方,我不会编程,所以我在 VB 脚本任务中还是个新手.
I assume I would use a Script Transformation but that is where I get stuck, I don't get to program much so I am pretty novice in the VB Script Tasks.
可能值得一提的是,这是在 FOR each 循环中抓取文件夹中的所有文件.通常只有一个文件,但我正在为可能的倍数腾出空间,文件名是文件名的变量表达式:@[User::FileName]
Might be worth mentioning this is in a FOR each loop to grab all files within a folder. There is usually only one file but I am making room for the potential of multiples and the file name is a variable expression of the filename: @[User::FileName]
我的假设是,一旦动态生成文件,您将失去指定列规则的能力.这就是为什么我正在寻找一种方法来修剪每一行的尾随逗号.
My assumption is that once the file is dynamically generated that you lose the ability to dictate the column rules. That is why I was looking for a way to trim the trailing comma of each row.
我得到的错误是
[Flat File Source [18]] Error: The column delimiter for column "Currentbal" was not found.
[Flat File Source [18]] Error: An error occurred while skipping data rows.
我认为这是因为尾随逗号告诉系统应该有另一列没有关联的标题.删除尾随逗号后,文件处理正常.
I assume it is because the trailing comma is telling the system there should be another column with no associated header. Once trailing commas are removed the file processes fine.
推荐答案
更简单的方法是更改连接管理器以跳过标题行.
An even simpler approach would be to change your connection manager to skip the header row.
- 要跳过的标题行:1
- 第一个数据行中的列名:未选中
这篇关于SSIS 2012:从 CSV 输出中修剪尾随逗号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:SSIS 2012:从 CSV 输出中修剪尾随逗号
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- SQL 临时表问题 2022-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 更改自动增量起始编号? 2021-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01