Skip to content

Instantly share code, notes, and snippets.

@chbaranowski
Forked from RainerW/csvconvertor.groovy
Created June 4, 2011 19:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chbaranowski/1008227 to your computer and use it in GitHub Desktop.
Save chbaranowski/1008227 to your computer and use it in GitHub Desktop.
Convert a CSV file into another CSV format in Java.
import java.io.*;
public class CsvConvertor {
public static void main(String[] args) throws Exception {
FileWriter out = new FileWriter("output.csv");
BufferedReader in = new BufferedReader(new FileReader("input.csv"));
String line;
while ((line = in.readLine()) != null) {
String[] fields = line.split(";");
String name = fields[2];
String firstname = fields[1];
String kto = fields[3];
String blz = fields[4];
String amount = fields[5];
out.append(
String.format("%s;%s %1$s;%s;%s;%s%n",
name, firstname,kto, blz, amount));
}
out.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment