Skip to content

Commit 1d6341f

Browse files
committed
Fix CSV parsing to preserve backslashes in file paths
Previously, OpenCSV was treating backslashes as escape characters, causing Windows file paths to be corrupted during parsing. Now using CSVParser with escape character disabled (NULL_CHARACTER) to ensure backslashes in paths are preserved exactly as written. Fixes issue where paths like "C:\Users\..." were being incorrectly parsed.
1 parent ca05c3a commit 1d6341f

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/main/java/fiji/plugin/trackmate/helper/ResultsCrawler.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
* it under the terms of the GNU General Public License as
99
* published by the Free Software Foundation, either version 3 of the
1010
* License, or (at your option) any later version.
11-
*
11+
*
1212
* This program is distributed in the hope that it will be useful,
1313
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1414
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1515
* GNU General Public License for more details.
16-
*
16+
*
1717
* You should have received a copy of the GNU General Public
1818
* License along with this program. If not, see
1919
* <http://www.gnu.org/licenses/gpl-3.0.html>.
@@ -47,6 +47,7 @@
4747

4848
import org.scijava.listeners.Listeners;
4949

50+
import com.opencsv.CSVParserBuilder;
5051
import com.opencsv.CSVReader;
5152
import com.opencsv.CSVReaderBuilder;
5253
import com.opencsv.exceptions.CsvValidationException;
@@ -167,7 +168,12 @@ public synchronized void crawl( final String resultsFolder ) throws IOException
167168
final List< String > csvFiles = findFiles( resultsFolder, "csv" );
168169
for ( final String csvFile : csvFiles )
169170
{
170-
try (CSVReader csvReader = new CSVReaderBuilder( new FileReader( csvFile ) ).build())
171+
try (CSVReader csvReader = new CSVReaderBuilder( new FileReader( csvFile ) )
172+
.withCSVParser(
173+
new CSVParserBuilder()
174+
.withEscapeChar( '\0' )
175+
.build() )
176+
.build())
171177
{
172178
final String[] readHeader = csvReader.readNext();
173179
if ( !type.isHeader( readHeader ) )

0 commit comments

Comments
 (0)