com.mindprod.csv
Class CSVReshape

java.lang.Object
  extended by com.mindprod.csv.CSVReshape

public final class CSVReshape
extends java.lang.Object

reshape a CSV file reordering, duplicating or removing fields.

Use: java.exe com.mindprod.CSVReshape somefile.csv 0 3 1 1 (0-based column numbers desired in output, if column in out past the end, will be empty)

Since:
2010-12-11
Version:
3.7 2011-02-17 now reorders the lead ## label comment, and leaves embedded col0 comments untouched.
Author:
Roedy Green, Canadian Mind Products

Constructor Summary
CSVReshape(java.io.File file, char separatorChar, char quoteChar, char commentChar, java.lang.String encoding, int... colsWanted)
          Reshape a CSV file, constructor.
 
Method Summary
static void main(java.lang.String[] args)
          Simple command line interface to Reshape.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CSVReshape

public CSVReshape(java.io.File file,
                  char separatorChar,
                  char quoteChar,
                  char commentChar,
                  java.lang.String encoding,
                  int... colsWanted)
           throws java.io.IOException
Reshape a CSV file, constructor. Just create the CSVReshape object.. There are no methods to call.

Parameters:
file - CSV file to be packed to remove excess space and quotes.
separatorChar - field separator character, usually ',' in North America, ';' in Europe and sometimes '\t' for tab.
quoteChar - char to use to enclose fields containing a separator, usually '\"'. Use (char)0 if you don't want a quote character.
commentChar - char to use to introduce comments. Use (char) 0 if none. Only one character allowed.
encoding - encoding of input and output.
colsWanted - list of columns wanted in the output file in order.
Throws:
java.io.IOException - if problems reading/writing file
Method Detail

main

public static void main(java.lang.String[] args)
Simple command line interface to Reshape. Reshapes one csv file whose name is on the command line. Must have extension .csv
Use java com.mindprod.CSVReshape somefile.csv 0 1 2 3 ... Output replaces input. If you want the input, make a copy first.

Parameters:
args - name of csv file to reshape, followed by zero-based cols wanted in desired order.