I have String as:
String cont = "[[\"START\",\"1001\",\"\",\"\",\"2014-07-15\",\"Invoice\",0,13.46,\"1682432\"]," +
"[\"START\",\"1001\",\"\",\"\",\"2014-07-15\",\"Invoice\",0,-13.46,\"1682432\"]," +
"[\"START\",\"1001\",\"\",\"\",\"2014-07-15\",\"Invoice\",0,-14.52,\"1682432\"]," +
"[\"START\",\"6002\",\"020\",\"0000000PWO\",\"2014-07-15\",\"MY Comment - FICA and\",-13.46,0,\"1682432\"]," +
"[\"START\",\"6002\",\"020\",\"0000000PWO\",\"2014-07-15\",\"MY Comment - FEED\",-1.06,0,\"1682432\"]" +
"]";
I need output as
Account || Date || Amount || Description || InvoiceNo
1001 2014-07-15 -13.46 1682432
....some more data
6002 2014-07-15 -1.06 MY desc 1682432
I am trying to use Apache CSV parser with version 2.3.
<dependency>
<groupId>net.sf.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>2.3</version>
</dependency>
java code:
CSVReader reader = new CSVReader(new StringReader(cont), ',');
List<String[]> records = reader.readAll();
Iterator<String[]> iterator = records.iterator();
while (iterator.hasNext()) {
String[] record = iterator.next();
for (String string : record) {
System.out.println(string);
}
}
output:
[[START
1001
2014-07-15
...
["START
6002
020
0000000PWO
2014-07-15
MY Comment - FEED
-1.06
0
1682432"]]
1) How do I remove the special character "[" and "]"
2) How do I assign values to above output fields
3) I want to convert above csv to bean object
4) bean to json