I have been trying to write to a CSV file from a JSON file using NorthConcepts datapipeline library in the following way, however I have problems. The data in the JSON file is either repeated or the fields are Seperated and written in different rows. For instance from the given code below I could have a combination of the following rows : Row 1 : CreatedAt, ID, Row 2 : CreatedAT, ID, IDString, Row 3 : CreatedAt, IDString likewise. I have about 30 fields and about 4 rows in the CSV file writing data for the same record but with split fields filled in. Would anyone know what the problem is? The JSON file I am reading from doesnt have repetitive data.
I read data the following way :
DataReader reader = new JsonReader(new File(FILE))
.addField("CreatedAt", "//array/object/created_at")
.addField("ID", "//array/object/id")
.addField("IDString", "//array/object/id_str")
.addField("Text", "//array/object/actualTweet")
Writing data the following way :
DataWriter writer = new CSVWriter(new File("../Twix/files/x.csv" ));
JobTemplate.DEFAULT.transfer(reader, writer);
The library used : http://northconcepts.com/data-pipeline/ javadocs : http://northconcepts.com/data-pipeline/javadocs/
Example CSV :
Name ProfileImageURL Location CreatedAt FollowRequestSent IsTranslator DefaultProfile FavouritesCount ContributorsEnabled
The Guardian London
The Guardian London
The Guardian London Thu Nov 05 23:49:19 +0000 2009 130
The Guardian London Thu Nov 05 23:49:19 +0000 2009 130
The Guardian London Thu Nov 05 23:49:19 +0000 2009 130
http://pbs.twimg.com/profile_images/2814613165/f3c9e3989acac29769ce01b920f526bb_normal.png FALSE FALSE FALSE FALSE
Here the URL given above is for the second column.
JsonReader.addRecordBreak()?