SSIS 解析不规则平面文件?
我非常熟悉常规分隔文本数据文件的 SSIS 解析,但是,我正在寻找一些有关处理类似于此测试文件的文件的方法的建议:
ISA*00* *00* *01*220220220 *ZZ*RL CODE 01*060327*1212*U*00300*000008859*0*P*:~
GS*RA*CPA-BPT*LOCALUTILITY*060319*1212*970819003*X*003030~
ST*820*000000001~
BPR*C*321.91*C*X12*CBC*04*000300488**9918939***04*000300002**1598564*070319~
TRN*1*00075319970819105029~
REF*RR*0003199708190000174858~
DTM*097*070318~
DTM*107*070318~
N1*PR*DIRECT PAYMENT~
N1*PE*ABC CORPORATE BILLER*ZZ*90005836~
ENT*1~
N1*PR*BILLING - TEST - NATTRASS~
RMR*CR*0009381082105011**142.15~
REF*TN*000303965~
DTM*109*070316~
ENT*2~
N1*PR*BILL FREID TEST~
RMR*CR*0011010451800011**179.76~
REF*TN*000304189~
321.91 是事务的总数。
我更喜欢使用 SSIS 来完成此操作,但也可以创建一个 C# 解析器。
如有建议,我们将不胜感激。
谢谢。
I'm pretty familiar with SSIS parsing of regular delimited text data files, however, I'm looking for some advice on an approach to tackle a file that looks like this test file:
ISA*00* *00* *01*220220220 *ZZ*RL CODE 01*060327*1212*U*00300*000008859*0*P*:~
GS*RA*CPA-BPT*LOCALUTILITY*060319*1212*970819003*X*003030~
ST*820*000000001~
BPR*C*321.91*C*X12*CBC*04*000300488**9918939***04*000300002**1598564*070319~
TRN*1*00075319970819105029~
REF*RR*0003199708190000174858~
DTM*097*070318~
DTM*107*070318~
N1*PR*DIRECT PAYMENT~
N1*PE*ABC CORPORATE BILLER*ZZ*90005836~
ENT*1~
N1*PR*BILLING - TEST - NATTRASS~
RMR*CR*0009381082105011**142.15~
REF*TN*000303965~
DTM*109*070316~
ENT*2~
N1*PR*BILL FREID TEST~
RMR*CR*0011010451800011**179.76~
REF*TN*000304189~
The 321.91 is the total of the transaction.
I would prefer to do this with SSIS, but could also do create a C# parser.
Suggestions would be appreciated.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
上面显示的文件称为“837 文件”。您可以搜索 837 文件解析器或在 C# 中解析此类文件的方法。我没有链接,但至少这应该至少可以帮助您找到解决方案(记住:“837 文件”)
(顺便说一句,我认为这违反了 HIPAA 规则。您不能在尽管数据可能是虚构的,但您不能真正发布这样的内容。)
2010 年 3 月 18 日更新:
我发现了一个 “如何阅读 ANSI 837 文件”文档(PDF 下载)
2010 年 3 月 26 日更新:
我找到了更多关于此的信息。该示例可能根本不是 837 文件。看起来它是 ANSI X12 - EDI 标准。请查看 EDI 映射文档 (pdf)
,还有此 < a href="http://www.google.com/search?hl=en&q=EDI+X12&aq=f&aqi=g10&aql=&oq=&gs_rfai=" rel="nofollow noreferrer ">EDI X12 上的 Google 搜索结果
而且,此针对程序员的 EDI 工具
请将解决方案发布到这个问题所以任何需要答案的人都会从中受益;-)
The file shown above is called a "837 File". You can search for 837 file parsers or ways to parse such file in c#. I don't have a link to that but at least this should at least help you find solution (remember: "837 File")
( By the way, I believe this is a violation of HIPAA rules. You cannot publish/post this in public. Although the data might be fictitious, you cannot really post something like this. Please double check that )
03/18/10 UPDATE:
I found a "How To Read the ANSI 837 File" doc here (PDF Download)
03/26/10 UPDATE:
I found more information on this. The example might not be an 837 file at all. It appears that it is an ANSI X12 - an EDI standard. Please take a look at EDI Mapping doc (pdf)
and, also this Google Search Result on EDI X12
And, this EDI Tools for Programmer
Please post solution to this problem so anybody who needs the answer will benefit from it ;-)
这个问题没有简单的答案。 SSIS 的平面文件数据源除了处理最简单的格式外不处理任何内容。我使用平面文件任务将参差不齐的右或记录类型的平面文件作为一大列读取。然后我通过脚本任务运行它来处理解析。抱歉,没有比这更简单的答案了……你会认为会有。
There is no easy answer to this. SSIS' Flat File data source does not handle anything but the simplest formats. I've used the flat file task to read in ragged right or reccord typed flat files as one big column. I'd then run it through a script task to handle the parsing. Sorry there is no easier answer than that... you'd think there would be.
对于常规平面文件数据源组件来说,该示例文件的处理过于复杂。使用 SSIS 执行此操作的唯一替代方法是使用脚本组件作为数据流中的源。然后,您将可以访问所有 .Net Framework 库,并且可以在该组件中创建自定义的 c# 或 vb(使用 2008)或 vb(使用 2005)解析器。祝你好运!
This sample file would be to complicated for a regular flat file data source component to handle. The only alternative to do this using SSIS would be to use the script component as a source in the data flow. You would then have access to all of the .Net Framework libraries and you would then be able to create your customized c# or vb (using 2008) or vb (using 2005) parser within that component. Good Luck!
假设在 SSIS 中执行此操作不是一个干净的选择,您可以使用开源 File Helpers 库来高效地编写 C# 解析器。
文件助手对于解析分隔文件和固定长度文件非常有用。
Assuming doing this in SSIS is not a clean option, you could use the open source File Helpers library in order to efficiently write a C# parser.
File Helpers are useful for parsing delimited files as well as fixed length files.