From 860c919cb117a032a5773874dd96abd09f08a339 Mon Sep 17 00:00:00 2001 From: Gabriel Vogel Date: Sun, 17 Mar 2024 23:35:09 +0100 Subject: [PATCH] Split CSV lines in at most 2 places --- .../scala-2.12/io/equiv/eqfiddle/ts/CSVTSLoader.scala | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/shared/src/main/scala-2.12/io/equiv/eqfiddle/ts/CSVTSLoader.scala b/shared/src/main/scala-2.12/io/equiv/eqfiddle/ts/CSVTSLoader.scala index 3767cb8..9cedaea 100644 --- a/shared/src/main/scala-2.12/io/equiv/eqfiddle/ts/CSVTSLoader.scala +++ b/shared/src/main/scala-2.12/io/equiv/eqfiddle/ts/CSVTSLoader.scala @@ -17,8 +17,13 @@ class CSVTSLoader( val relationTuples = new Queue[(Int, Symbol, Int)]() val bufferedSource = scala.io.Source.fromFile(tsFileName) for (line <- bufferedSource.getLines) { - val trans = line.split(",").map(_.trim) - relationTuples += (( trans(0).toInt, Symbol(trans(2)), trans(1).toInt )) + val firstComma = line.indexWhere(_ == ',', 0) + val secondComma = line.indexWhere(_ == ',', firstComma + 1) + val start = line.slice(0, firstComma).trim + val end = line.slice(firstComma + 1, secondComma).trim + val label = line.slice(secondComma + 1, line.size).trim + + relationTuples += (( start.toInt, Symbol(label), end.toInt )) } bufferedSource.close