Issue
i try to read a csv file with opencsv
Prozess;Rüstvorgang;Prozessdauer Minuten;Station;Küvettentyp;Küvettentemperatur Grad Celsius;Werker;Gasmischung;GasKonzentration PPM
Test;X;;Y;K10;;X1;;
ACVB;;60;ERT;K10;400;;;
SSD;;10;ERER;K10;400;X;;
My class:
public class ABC
{
@CsvBindByPosition(position = 0)
private String prozess;
@CsvBindByPosition(position = 1)
private String ruestVorgang;
@CsvBindByPosition(position = 2)
private String prozessDauerMinuten;
@CsvBindByPosition(position = 3)
private String station;
@CsvBindByPosition(position = 4)
private String kuevettenTyp;
@CsvBindByPosition(position = 5)
private String kuevettenTemperatur;
@CsvBindByPosition(position = 6)
private String werker;
@CsvBindByPosition(position = 7)
private String gasMischung;
@CsvBindByPosition(position = 8)
private String gasKonzentration;
The beanBuilder
List<ABC> beans = new CsvToBeanBuilder(new FileReader("etestcsv"))
.withType(ABC.class)
.build()
.parse();
Just the prozess is filled with the values of all columns, the rest is null. I tried also with CsvBindByName
but everything is null.
implementation 'com.opencsv:opencsv:5.3'
Solution
Go for:
List<ABC> beans = new CsvToBeanBuilder(new FileReader("etestcsv"))
.withType(ABC.class)
.withSeparator(';')
.build()
.parse();
and you should see better results.
Answered By - MWiesner Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.