From 249c178e6d2f7abebc6fcce44cd3d73936dda1cd Mon Sep 17 00:00:00 2001 From: Reuben Roberts Date: Tue, 7 Aug 2018 13:03:29 +0100 Subject: [PATCH] Fix read of source file columns The original values give 'array index out of bounds' errors. The source file (e.g. dd_data_NBNSYS0000188576.txt) has only 17 columns, of which the last two seem to be what is desired here. See also the definition of fieldsToExport, which is used to create the source file in the first place. --- .../org/ala/biocache/tool/DuplicationDetection.scala | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/scala/au/org/ala/biocache/tool/DuplicationDetection.scala b/src/main/scala/au/org/ala/biocache/tool/DuplicationDetection.scala index f44a4fddd..faae07c13 100644 --- a/src/main/scala/au/org/ala/biocache/tool/DuplicationDetection.scala +++ b/src/main/scala/au/org/ala/biocache/tool/DuplicationDetection.scala @@ -404,8 +404,8 @@ class DuplicationDetection { collector, oldStatus, oldDuplicateOf, - currentLine(24), - currentLine(25)) + currentLine(15), + currentLine(16)) } else { logger.warn("lsid " + currentLine(0) + " line " + counter + " has incorrect number of columns: " + currentLine.size + ", vs " + fieldsToExport.length) @@ -690,7 +690,7 @@ class DuplicationDetection { //open the tmp file that contains the information about the lsid val reader = new CSVReader(new FileReader(sourceFileName), '\t', '`', '~') - var currentLine = reader.readNext //first line is header + var currentLine = reader.readNext //first line is data, not header val buff = new ArrayBuffer[DuplicateRecordDetails] var counter = 0 @@ -717,7 +717,7 @@ class DuplicationDetection { val oldDuplicateOf = StringUtils.trimToNull(currentLine(14).replaceAll("\\[", "").replaceAll("\\]", "")) buff += new DuplicateRecordDetails(rowKey, rowKey, taxon_lsid, year, month, day, currentLine(5), currentLine(6), currentLine(7), currentLine(8), currentLine(9), currentLine(10), rawName, collector, oldStatus, oldDuplicateOf, - currentLine(24), currentLine(25)) + currentLine(15), currentLine(16)) } else { logger.warn("lsid " + lsid + " line " + counter + " has incorrect column number: " + currentLine.size) } @@ -1151,4 +1151,4 @@ class DuplicationDetection { true } } -} \ No newline at end of file +}