【问题标题】:Duplicate Lines (Data) checking in Multiple Files检查多个文件中的重复行(数据)
【发布时间】:2019-10-03 08:13:50
【问题描述】:

我从 Jmeter 响应数据中创建了多个序列号重复的文件。

Duplicate.txt    Duplicate1.txt      Duplicate2.txt Etc.....

C5FV55WGJ1       C5FV55WGJ1
C5FX1N2572       C5FX1N2578
C5G0F54VP3       C5G0F54VP9
C5G77R09C4       C5G77R0910
C5G7L33Y25       C5G7L33Y11
C5G7X7NWY6       C5G7X7NW12
C5FX1N2577       C5FX1N2513

像上面的 txt 数据文件一样,我在一个目录中有多个文件。现在我想将所有 .txt 文件与每个 .txt 文件进行比较。

如果重复发现任何序列号 .txt 文件,想在 Jmeter Groovy Jmeter PostProcessor 中创建一个带有序列号和 .txt 文件的 Double Duplicate.txt 文件。

exp;

Double Duplicate.txt

C5FV55WGJ1 (Duplicate.txt & Duplicate1.txt)

你们能帮我解决这个问题吗?提前致谢!

【问题讨论】:

    标签: java groovy jmeter performance-testing


    【解决方案1】:

    Stackoverflow 不是代码编写服务,如果您希望有人为您实现代码,您应该询问您的一位同事或通过freelance website 雇用某人。

    在这里,您应该提供自己的解决方案,该解决方案要么由于某种原因无法正常工作,要么无法按您的预期工作并请求帮助,而不是端到端-结束实施。

    作为一个例外,您可以使用以下代码 sn-p:

    new File('/path/to/folder/with/your/duplicate/files').listFiles().each { file ->
        List<String> lines = file.readLines()
        new File('/path/to/folder/with/your/duplicate/files').listFiles(new FilenameFilter() {
            @Override
            boolean accept(File dir, String name) {
                return !file.getName().equals(name)
            }
        }).each { otherfile ->
            List<String> otherLines = otherfile.readLines()
            lines.each { line ->
                if (otherLines.contains(line)) {
                    new File('Double Duplicate.txt') << line << ' ('<< file.getName() << ' & ' << otherfile.getName() << ')' << System.getProperty('line.separator')
                }
            }
        }
    }
    

    更多信息:

    【讨论】:

      猜你喜欢
      • 2021-01-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-11
      • 1970-01-01
      • 1970-01-01
      • 2016-05-01
      • 1970-01-01
      相关资源
      最近更新 更多