需要将 Cobol 数据文件转换为 CSV、Excel
我有一个没有文件扩展名的 COBOL 数据文件。我需要将其转换为任何类型的现代数据文件,例如上面提到的。 我可以在 Windows 上使用记事本打开该文件。
这是里面的代码示例,
0~ 9401131218264194011312182641 > ֽ ֽ A ֵ @ֽB1993120901758501000232GE93DO 2PECALR 1MF000232Y A10000 @ֽB1993120901758601004407GE93DO % 2PECALR 1MF004407Y A10000 @ֽB1993120901758701005444GE93DO `2PECALR 1MF005444Y A10000 @ֽB1993120901758801000008GE93DO 2PECALR 1MF000008Y A10000 @ֽB1993120901758901001518GE93DO €2PECALR 1MF001518Y A10000 @ֽB1993120901759001000102GE93DO €2PECALR 1MF000102Y A10000 @ֽB1993120901759101001605LA93LA 2 2MF001605N A20000 @ֽB1993120901759201001076GE93DO P 2PECALR 1MF001076Y A10000 @ֽB1993120901759301001608GE93DO % 2PECALR 1MF001608Y A10000 @ֽB1993120901759401007044GE93DO 5 2PECALR 1MF007044Y A10000 @ֽB1993120901759501000329GE93DO P 2PECALR 1MF000329Y A10000 @ֽB1993120901759601000613MM93MS P 2PECALR 1MF000613Y A10000 @ֽB1993120901759701000516MM94MS 2PECALR
我什至不知道从哪里开始寻找如何实现这一点。 任何帮助将不胜感激。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您在这里得到的并不是真正的 COBOL 数据文件本身。它是一个没有强加结构的平面数据文件。它当然可以由 COBOL 程序编写。
要理解这一点,您需要一本定义各种数据字段的抄本。虽然我不能确定,但如果我不得不冒险猜测,我会说这是标题材料
0~ 9401131218264194011312182641 > ֽ ֽ A ֵ
然后你就有了多条记录,每条记录都以@开头。这可能是一条记录:
现在您需要的是结构。您可以访问 COBOL 源代码吗?如果没有它(或者抄写本的副本),我担心可能无法确定这些数据应该意味着什么。
What you've got here is not really a COBOL data file per se. It's a flat data file without a structure imposed on it. It certainly could be written by a COBOL program.
What you need to make sense of this would be a copybook that defines what the various data fields even are. While I can't be sure, if I had to hazard a guess I'd say that this is header material
0~ 9401131218264194011312182641 > ֽ ֽ A ֵ
and then you have multiple records, each one starting at @. This would likely be one record:
Now what you need is the structure. Do you have access to the COBOL source code? Without it (or else a copy of the copybook) I'm afraid there's probably no way to determine what this data is supposed to signify.
如果您必须一遍又一遍地执行此操作,或者文件很长,您可以从用
cobol 编写程序中选择两种方法,在字段之间添加逗号并创建新文件。然后,您可以在 Excel 中以 csv 格式打开该文件。
或者
编写一个 Excel 宏。在一张表中提供结构,即一列中的字段类型和另一列中的字段长度。该宏将读取文件的结构,并根据文本的长度将文本拆分为多列。您可以查看 此链接了解有关如何编写宏的一些想法。
If you have to do this over and over or the file is very long, there are two things you can choose from
Write a program in cobol that will add commas between the fields and create a new file. You can then open that file as a csv in Excel.
OR
Write an excel macro. In one sheet provide the structure i.e. the type of the field in one column and the length in another column. The macro will read the structure of the file and split the text in multiple columns based on their length. You can look at this link for some idea on how to write the macro.
好吧,由于它是 COBOL 输出,因此每个字段的长度从记录到记录都是一致的。
如果这是一项一次性任务,我只需在 Excel 中打开它并使用文本到列并手动设置分割点以将每个字段放入其自己的单元格中。
如果这不是一次性的,我只需修改生成输出的程序,以便在输出记录中的每个字段之间有一个逗号。
Well, since it's COBOL output every field length will be consistent from record to record.
If this is a one-time task I'd just open it in excel and use text to columns and manually set split points to get each field into its own cell.
If this isn't a one-off I'd just modify the program that produces the output to have a comma between each field in the output record.
RecordEditor / 文件向导 .net/projects/jrecord/develop/" rel="nofollow">JRecord 可以搜索文件中的 Mainframe Cobol 字段。 文件向导结果可以存储在 Xml 文件中以供其他语言使用,或者您可以使用复制功能从 Ebcdic 复制为 Ascii 固定格式或 CSV 格式。
文件向导上有一些过时的文档
The FileWizard in RecordEditor / JRecord can search for Mainframe Cobol fields in a Files. The FileWizard results can be stored in a Xml file for use in other languages or you can use the copy Function to copy from Ebcdic to either Ascii fixed or CSV formats.
There is some out of date documentation on the File Wizard