-2

Im reading from a .csv file and I'm getting this weird numbers at the start of each line

12195820118109888100071.53 something like this, what do you think it could be my mistake

while ((line = bufRdr.readLine()) != null) {
    input = line.split(",");
    System.out.println(line);

That is what im using and printing each line. The first line is correct, but the second line onwards I see a string of numbers like this: 69363520177627835700077.119. Help me please.

Fred Foo
  • 355,277
  • 75
  • 744
  • 836
user1212697
  • 619
  • 1
  • 6
  • 7

1 Answers1

2

Normally CSV file content are separated by comma but in some case it could be tabulation delimited format, MySQL or excel generated format. You can use Apache Commons CSV, it can handle DEFAULT,EXCEL,MYSQL or TDF format of csv file. For Example -

Reader in = new StringReader("a,b,c");
for (String[] line : CSVFormat.DEFAULT.parse(in)) {
    for (int i = 0; i < line.length; i++) {
        System.out.println("value " + i + "=" + line[i]);
    }
}
  • DEFAULT - Standard comma separated format
  • EXCEL - Excel file format
  • MYSQL - Default MySQL format
  • TDF - Tabulation delimited format
Subhrajyoti Majumder
  • 40,646
  • 13
  • 77
  • 103