~pbeaman/+junk/sandbox

« back to all changes in this revision

Viewing changes to src/FixText.java

  • Committer: Peter Beaman
  • Date: 2011-08-31 15:56:37 UTC
  • Revision ID: pbeaman@akiban.com-20110831155637-cp1nrrty9ylvy3ww
Put sandbox under bzr

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import java.io.BufferedInputStream;
 
2
import java.io.DataInputStream;
 
3
import java.io.FileInputStream;
 
4
 
 
5
public class FixText {
 
6
 
 
7
    public static void main(String[] args) throws Exception {
 
8
        final DataInputStream is = new DataInputStream(new BufferedInputStream(new FileInputStream("boa.txt")));
 
9
        for (;;) {
 
10
            final String line = is.readLine();
 
11
            if (line == null) {
 
12
                break;
 
13
            }
 
14
            String[] s = line.split(" ");
 
15
            String date = s[0].substring(0, 2) + "/" + s[0].substring(3, 5) + "/2010";
 
16
            String amount = s[1].substring(s[1].length() - 1) + s[1].substring(0, s[1].length() - 1);
 
17
            amount = amount.replace(",", "");
 
18
            String desc = "";
 
19
            for (int k = 3; k < s.length; k++) {
 
20
                desc = desc + s[k] + " ";
 
21
            }
 
22
            System.out.println(date + "," + amount + ",,\"" + desc + "\"");
 
23
        }
 
24
    }
 
25
}