uniVocity / univocity-parsers

uniVocity-parsers is a suite of extremely fast and reliable parsers for Java. It provides a consistent interface for handling different file formats, and a solid framework for the development of new parsers.
917 stars 252 forks source link

mapping nested beans to multiple lines in a file! #437

Closed niksrivastav closed 3 years ago

niksrivastav commented 3 years ago

i am working in a camel project where i have a .DAT file from which i am trying to populate my data in my nested beans and then after some changes from populated beans i am trying to generate a file which have data present in those beans.

my POJO's are like:

class POJO1{
field a;
field b;
list<class POJO2>;
list<class POJO3>;
}

class POJO2{
field c;
field d;
field e;
field f;
}

class POJO3{
field g;
field h;
field i;
field j;
}

and my file looks like this

a|b
c|d|e|f
g|h|i|k
a|b
c|d|e|f
g|h|i|k
a|b
c|d|e|f
g|h|i|k
a|b
c|d|e|f
g|h|i|k

which is mapped to fields of POJO's. Can you please help me to achieve this functionality.

jbax commented 3 years ago

Check this example: https://github.com/uniVocity/univocity-parsers/blob/e09114c6879fa6c2c15e7365abc02cda3e193ff7/src/test/java/com/univocity/parsers/examples/CsvParserExamples.java#L664-L736