平面文件中的 SSIS 列计数
我正在尝试找到一种方法来计算来自平面文件的列数。实际上,我的所有列都连接在一个符号单元格中,并用“|”分隔,
经过各种尝试,似乎只有脚本任务可以处理这个问题。 有人可以帮助我吗?遗憾的是,我没有使用 C# 或 VB 脚本的经验。
多谢 为了更好地理解
,以下是我想要实现的输出。例如,包含来自 FF 的所有标头的单个单元格。问题是,为了得到这个结果,我在上一步(派生列)中手动附加了所有列名称,以便用“|”将它们连接起来分隔符。 现在,如果我的 FF 源布局发生变化,由于这个手动过程,它将不再工作。所以我想我必须使用一个脚本,它基本上返回变量中的列数( header ),并且允许删除派生列 transfo 中的硬编码部分
I'm trying to find a way to count my columns coming from a Flat File. Actually, all my columns are concatened in a signe cell, sepatared with a '|' ,
after various attempts, it seems that only a script task can handle this.
Does anyone can help me upon that ? I've shamely no experience with script in C# ou VB.
Thanks a lot
Emmanuel
To better understand, below is the output of what I want to achieve to. e.g a single cell containing all headers coming from a FF. The thing is, to get to this result, I appended manually in the previous step ( derived column) all column names each others in order to concatenate them with a '|' separator.
Now , if my FF source layout changes, it won't work anymore, because of this manualy process. So I think I would have to use a script instead which basically returns my number of columns (header ) in a variable and will allow to remove the hard coded part in the derived column transfo for instance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个非常古老的线程;然而,我偶然发现了类似的问题。内部有多种不同记录“格式”的平面文件。许多不同的格式,没有任何特定的顺序,这意味着一行中可能有 57 个字段,然后接下来的 1000 个字段中有 59 个字段,然后接下来的 10000 个字段中有 56 个字段,最后回到 57 个......好吧,我想你明白了。
由于缺乏更好的想法,我决定根据每行中的逗号数量来破坏该文件,然后使用每种类型的 SSIS 包导入不同的记录类型(现在聚集在一起)。
所以这个问题的答案就在那里,需要更多的代码来生成文件。
希望这可以帮助遇到同样问题的人。
This is an very old thread; however, I just stumbled on a similar problem. A flat file with a number of different record "formats" inside. Many different formats, not in any particular order, meaning you might have 57 fields in one line, then 59 in the next 1000, then 56 in the next 10000, back to 57... well, think you got the idea.
For lack of better ideas, I decided to break that file based on the number of commas in each line, and then import the different record types (now bunched together) using SSIS packages for each type.
So the answer for this question is there, with a bit more code to produce the files.
Hope this helps somebody with the same problem.
请参考我在以下
Stack Overflow
问题中的回答。这些答案可能会让您了解如何加载包含不同列数的平面文件。以下问题中的示例读取包含由特殊字符
Ç (c-cedilla)
分隔的数据的文件。在您的情况下,分隔符是竖线 (|)
UTF-8 平面文件导入到 SQL Server 2008 时无法识别 {LF} 行分隔符
示例如下问题读取一个 EDI 文件,其中包含具有不同列数的不同部分。包读取文件并将其与父子关系相应地加载到 SQL 表中。
如何将具有标头和详细信息父子关系的平面文件加载到 SQL Server
根据这些答案中使用的逻辑,您还可以通过以下方式计算列数通过列分隔符
(Vertical Bar |)
拆分文件中的行。希望有帮助。
Please refer my answers in the following
Stack Overflow
questions. Those answers might give you an idea of how to load a flat file that contains varying number of columns.Example in the following question reads a file containing data separated by special character
Ç (c-cedilla)
. In your case, the delimiter isVertical Bar (|)
UTF-8 flat file import to SQL Server 2008 not recognizing {LF} row delimiter
Example in the following question reads an EDI file that contains different sections with varying number of columns. The package reads the file loads it accordingly with parent-child relationships into an SQL table.
how to load a flat file with header and detail parent child relationship into SQL server
Based on the logic used in those answers, you can also count the number of columns by splitting the rows in the file by the column delimiter
(Vertical Bar |)
.Hope that helps.