Ruby::Install Mechanize

Mechanize is a library used for automating interaction with websites. It uses by Perl, PHP, & Ruby.
Write down how to install Mechanize in Ruby(You need to have installed Nokogiri already because Mechanize depends on Nokogiri.)

$ sudo apt-get install g++
$ sudo gem install mechanize

Java::OpenCSV

OpenCSV , a library in Java, allows you to read and write CSV files.
This is a way to install OpenCSV in Linux Mint(14).

// download
$ wget http://sourceforge.net/projects/opencsv/files/opencsv/2.3/opencsv-2.3-src-with-libs.tar.gz
// expand the downloaded file
$ tar zxvf opencsv-2.3-src-with-libs.tar.gz
// copy a jar file
$ sudo cp opencsv-2.3/deploy/opencsv-2.3.jar /usr/share/java/

A sample java file(SampleCSV.java) to read and write a CSV file

import au.com.bytecode.opencsv.CSVReader;
import au.com.bytecode.opencsv.CSVWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
 
public class SampleCSV{

  public static void main (String[] args){

    final String READ_FILENAME = args[0];
    final String WRITE_FILENAME = args[1];

    try{
      //////////////////////////////////////////////
      // read csv
      CSVReader reader = new CSVReader(new FileReader(READ_FILENAME));
      String [] nextLine;
      while ((nextLine = reader.readNext()) != null) {
			  System.out.println("Col1 : " + nextLine[0] + " , \tCol2 : " + nextLine[1]);
      }
      //////////////////////////////////////////////
      // write csv
      CSVWriter writer = new CSVWriter(new FileWriter(WRITE_FILENAME));

      String[][] writeLine={{"北海道","札幌"}, {"岩手","盛岡"}};

      for(String[] wl: writeLine){
        writer.writeNext(wl);
      }
      writer.flush();

    }catch(IOException e){
      System.out.println(e);
    }

  }  // public static void main (String[] args){
} // public class SampleCSV{

sample.dat (the above java file uses this csv file)

港区,1001
中央区,1002
文京区,1003

Compile the java file

$ javac -cp /usr/share/java/opencsv-2.3.jar SampleCSV.java

Run the java
The first argument is a file to be read and the second is a file to be written.

$ java -cp /usr/share/java/opencsv-2.3.jar:. SampleCSV sample.dat out.csv

Standard Output(in Terminal)

Col1 : 港区 , 	Col2 : 1001
Col1 : 中央区 , 	Col2 : 1002
Col1 : 文京区 , 	Col2 : 1003

out.csv

"北海道","札幌"
"岩手","盛岡"