I asked similar question before but haven't solved it yet.
I have amazon review data set and would like to convert it into csv format in JAVA. The original data that I have look like as follows:
product/productId: B00032K32A
product/title: Cruiser Accessories 21330 Slim Rim, Chrome License Plate Frame
product/price: 4.99
review/userId: A2O41UFL8HAQWV
review/profileName: Nick Nefsik
review/helpfulness: 4/4
review/score: 5.0
review/time: 1239667200
review/summary: It's slim, alright!
review/text: Similar to another review, I also found that this frame is more of a overlay to a license plate (sits on top of the plate), as opposed to securing the plate underneath it, if that makes sense.It just covers the edges of my AZ plate, which is fine, but I sure wouldn't want it to be any smaller around its outside perimeter. I also ordered the chrome covers for the screws (Cruiser Accessories 82030 Screw Covers, Chrome) that I was already using, and, altogether, it looks great, and is exactly the look I was going for.
product/productId: B00032K32A
product/title: Cruiser Accessories 21330 Slim Rim, Chrome License Plate Frame
product/price: 4.99
review/userId: A3V7H58BH72AYT
review/profileName: Illustratedman
review/helpfulness: 6/7
review/score: 5.0
review/time: 1199145600
review/summary: Nice...
review/text: I first purchased these for my new 2008 Honda Accord EX-L to complement
I want the output to be
product id,title,price,userid,profileName,helpfulness,score,time,summary,text
B00032k32A,Cruser accessories..,4.99,A3v7...,illustratedam,6/7,5.0,1199145600,nice..,i first purchased these fr my new .......
B00032k302X,Cruser accessories..,3.95,A3v7...,illustedam,2/7,4.0,1193445600,nice..,i first purchased these for my new .......
I have a pretty big data of 5GB. So i want to write to file.
I am a newbee to java and tried several different ways but still haven't succeeded it yet. Are there anyone who has a good thought about converting the original data type into csv format?
Thanks
This is the code that i wrote
**public class ConvertToCsv {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new FileReader("data/Movies.txt"));
BufferedWriter bw = new BufferedWriter(new FileWriter("data/movies.csv"));
String line;
while((line = br.readLine()) != null){
String[] values = line.split("/",-1);
bw.write(values[0]+","+values[1]+","+values[2]+","+values[3]+","+values[4]+","+values[5]+","+values[6]+","+values[7]+","+values[8]+","+values[9]+"\n");
}
br.close();
bw.close();
}
}
But it does not have the desired effect.