import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

public class Parser {
	public static void main(String args[]) {
       System.out.println("Hello World!");
       List stuff = null;
       PrintWriter pw = null;
       String inFile = "[PUT FILE NAME HERE, MINUS EXTENSION]";
       
       try {
    	   stuff = readFile(inFile + ".csv");
       } catch (Exception e) {
    	   e.printStackTrace();
       }
       
	   try {
		   pw = new PrintWriter(new FileWriter("2" + inFile + ".csv"));	
	   } catch (IOException e) {
		   e.printStackTrace();
	   }
       
	   //CSV Youtube Comment files.
	   for (int i = 0; i &lt; stuff.size(); i++) {
		   if (i == 1) {
			   pw.println("id,user,date,timestamp,commentText,likes,hasReplies,numberOfReplies");
		   }
		   else if (stuff.get(i).substring(0, 8).equals(",,,,,,,,")) {
			   pw.println(stuff.get(i).substring(8) + ",is_reply,0");
		   }
		   else {
			   pw.println(stuff.get(i).substring(0, stuff.get(i).length() - 6));
		   }
	   }
	   
       pw.close();
	   System.out.println("Goodbye.");
	}
	
	private static List readFile(String filename) throws Exception {
		String line = null;
		List records = new ArrayList();
			 
		// wrap a BufferedReader around FileReader
		BufferedReader bufferedReader = new BufferedReader(new FileReader(filename));
			 
		// use the readLine method of the BufferedReader to read one line at a time.
		// the readLine method returns null when there is nothing else to read.
		while ((line = bufferedReader.readLine()) != null) {
			records.add(line);
		}
	
		// close the BufferedReader when we're done
		bufferedReader.close();
		return records;
	}
}
