Last active
August 29, 2015 13:57
-
-
Save andrewmd5/9656382 to your computer and use it in GitHub Desktop.
Cleans out a paypal cvs document to only leave what you received
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CVSFormat { | |
public static void main(String[]args)throws IOException { | |
// construct temporary file | |
File inputFile = new File("statements.csv"); | |
File tempFile = new File(inputFile + "temp.csv"); | |
BufferedReader bufferReader = new BufferedReader (new FileReader("statements.csv")); | |
PrintWriter printWriter = new PrintWriter(new FileWriter (tempFile)); | |
String line = null; | |
//read from original, write to temporary and trim space, while title not found | |
while((line = bufferReader.readLine()) !=null) { | |
if(line.toLowerCase().contains("received")){ | |
System.out.println(line); | |
printWriter.println(line); | |
printWriter.flush(); | |
} else{ | |
continue; | |
} | |
} | |
// close readers and writers | |
bufferReader.close(); | |
printWriter.close(); | |
// delete book file before renaming temp | |
inputFile.delete(); | |
// rename temp file back to statements.cvs | |
if(tempFile.renameTo(inputFile)){ | |
System.out.println("Update succesful"); | |
}else{ | |
System.out.println("Update failed"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment