Posts mit dem Label AWK werden angezeigt. Alle Posts anzeigen
Posts mit dem Label AWK werden angezeigt. Alle Posts anzeigen

Sonntag, 5. Juni 2011

Convert a simple CSV File with Groovy, Java, Scala, awk, Ruby, Python, PHP or Bash?

Change Log:
  • 05.06.2011 1:30 pm - Initial created Post with  Groovy, Java, Scala, awk, Ruby, Python Implementation
  • 05.06.2011 4:00 pm - Add PHP implementation and update voting (now you can vote for PHP).
  • 06.06.2011 4:00 pm - Add Bash implementation and update voting (now you can also vote for Bash)

Which is the best programming language for converting a simple CSV into another format?

First I blogged three Java VM based solutions written in Groovy, Java and Scala to convert a simple CSV file into another format. Rainer sends me the Java based solution, yesterday Axel Knauf sends an awk based solution, Niko sends Ruby based solution, Hendrik sends a Python based solution, Sebastian sends me a PHP implementation and Julien sends a Bash version. Now there are a Groovy, Java, Scala, awk, Ruby, Python, PHP and Bash implementation.

Now here again a complete overview of the different implementations:

The Groovy Implementation:

The Java Implementation:

The Scala Implementation:

Here the shell command and awk script:

The pure Ruby Implementation:

The Python Implementation:

The pure PHP Implementation:

The Bash Implementation:


I'm curious whether there are other implementation proposals (Clojure, Perl, PHP, …), if you have one you could send me the script via Twitter or leave a comment here…

I am also curious which implementation Groovy, Java, Scala, awk or Ruby you like and why? I have create voting here:


Thanks Rainer, Axel Knauf, Niko Dittmann, Hendrik Heimbuerger S.Barthenheier and Julien Guitton for the Java, awk, Ruby Python, PHP and Bash implementation.

Links:

Convert a CSV File with awk

Yesterday I post three Java VM based solutions written in Groovy, Java and Scala to convert a simple CSV file into another format. Today kopfkind sends me via Twitter a awk based solution.

Here the shell command and awk script to convert the CSV file:

Thanks a lot @kopfkind for this simple solution. I'm curious whether there are other implementation proposals (Python, Clojure, Perl, Bash, PHP, …), if you have one you could send me the solution via Twitter or leave a comment here.

I am also curious which implementation Groovy, Java, Scala or awk you like and why?

See also: Convert a CSV File in Groovy, Java or Scala?