首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >比较两个平面文件的记录,并将FILE-1的不匹配记录写入输出

比较两个平面文件的记录,并将FILE-1的不匹配记录写入输出
EN

Stack Overflow用户
提问于 2019-08-06 22:55:39
回答 2查看 442关注 0票数 0

我有两个文件File-1和File-2。两个文件中的记录都是按降序排列的。File-1的顶部可能有一些额外的记录。我想写入File-1中不存在于File-2中的所有记录。

代码语言:javascript
复制
File-1:- Sample
2019-08-06 XXXX
2019-08-06 XYXX
2019-08-06 XXYX
2019-08-05 XXYX
2019-08-05 XXYY
2019-08-04 XXYX
2019-08-03 XXYX
2019-08-03 XZYX

File-2:- Sample
2019-08-05 XXYX
2019-08-05 XXYY
2019-08-04 XXYX
2019-08-03 XXXX
2019-08-03 XZYX


Output:-
2019-08-06 XXXX
2019-08-06 XYXX
2019-08-06 XXYX
2019-08-03 XXYX

请让我知道伪码。

EN

回答 2

Stack Overflow用户

发布于 2019-09-21 09:45:16

代码语言:javascript
复制
Open both input files for reading
Open output file for writing
while not eof file2
read file2
    while file1 > file2 and not eof file1
        read file1
        write file1 to output
    end while  
end while
票数 0
EN

Stack Overflow用户

发布于 2019-10-15 17:04:32

代码语言:javascript
复制
PERFORM 000-OPEN.
PERFORM 100-PROCESS THRU 100-PROCESS-EXIT
UNTILL END-File-1 AND END-File-2. (Where END-File will be declare as PIC X(2) VALUE '10')
PERFORM 200-CLOSE-FILE THRU 200-CLOSE-FILE-EXIT.
*************************************************************
000-OPEN.
will perform opening the 2 files in INPUT mode and 3 output file in OUTPUT 
mode.
000-OPEN-EXIT.
**
100-PROCESS.
**
will perform READ operation for 2 input files, then will compare first 
record from both files.

IF File-1(REC-1) NOT= File-2(REC-1)
WRITE File-3 (For unmatched Records)
READ File-1 AND File-2.
END-IF.
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57378850

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档