Skip to content

DoubleParser.canParse crashed by single comma value. #1043

@is

Description

@is
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
	at java.base/java.lang.StringLatin1.charAt(StringLatin1.java:48)
	at java.base/java.lang.String.charAt(String.java:1512)
	at tech.tablesaw.columns.numbers.DoubleParser.isPercent(DoubleParser.java:60)
	at tech.tablesaw.columns.numbers.DoubleParser.canParse(DoubleParser.java:29)
	at tech.tablesaw.io.ColumnTypeDetector.detectType(ColumnTypeDetector.java:155)
	at tech.tablesaw.io.ColumnTypeDetector.detectColumnTypes(ColumnTypeDetector.java:100)
	at tech.tablesaw.io.FileReader.getColumnTypes(FileReader.java:58)
	at tech.tablesaw.io.csv.CsvReader.detectColumnTypes(CsvReader.java:156)
	at tech.tablesaw.io.csv.CsvReader.getReaderAndColumnTypes(CsvReader.java:75)
	at tech.tablesaw.io.csv.CsvReader.read(CsvReader.java:92)
	at tech.tablesaw.io.csv.CsvReader.read(CsvReader.java:87)
	at tech.tablesaw.io.csv.CsvReader.read(CsvReader.java:34)
	at tech.tablesaw.io.DataFrameReader.usingOptions(DataFrameReader.java:139)

The csv file

token,title,event,context,advice,total
",",11427,587954,152285,360184,1111850
the,2850,450041,172617,372166,997674
.,612,406092,112307,349705,868716
be,859,315897,99111,272848,688715
and,7132,303502,90898,282893,684425

When cheked string is ",", it will be stripped to an empty string, but the followed catch statement do not catch StringIndexOutOfBoundsException exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions