Skip to content

Instantly share code, notes, and snippets.

@RainerW
Forked from chbaranowski/csvconvertor.groovy
Created June 3, 2011 17:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save RainerW/1006757 to your computer and use it in GitHub Desktop.
Save RainerW/1006757 to your computer and use it in GitHub Desktop.
Convert a CSV file into another CSV format.
public class CsvSplit
{
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