com.mindprod.csv
Class CSVPack

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

public final class CSVPack
extends java.lang.Object

pack a CSV File as densely as possible, removing excess space and commas.

Use: java.exe com.mindprod.CSVPack somefile.csv

Since:
1998
Version:
3.7 2011-02-17 tidy up the label comment
Author:
Roedy Green, Canadian Mind Products

Field Summary
(package private) static java.util.regex.Pattern SPLITTER
          used to split Label comment fields apart
 
Constructor Summary
CSVPack(java.io.File file, char separatorChar, char quoteChar, char commentChar, java.lang.String encoding)
          pack a CSV file, constructor.
 
Method Summary
static void main(java.lang.String[] args)
          Simple command line interface to CSVPack.
(package private) static java.lang.String rebuildLabelComment(java.lang.String comment)
          comment has two lead comment chars, one stripped off, and are used to label the fields.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SPLITTER

static final java.util.regex.Pattern SPLITTER
used to split Label comment fields apart

Constructor Detail

CSVPack

public CSVPack(java.io.File file,
               char separatorChar,
               char quoteChar,
               char commentChar,
               java.lang.String encoding)
        throws java.io.IOException
pack a CSV file, constructor. Just create. 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.
Throws:
java.io.IOException - if problems reading/writing file
Method Detail

rebuildLabelComment

static java.lang.String rebuildLabelComment(java.lang.String comment)
comment has two lead comment chars, one stripped off, and are used to label the fields. Reshape it so it labels the new fields.

Parameters:
comment - field names separated by commas, with lead comment char.
Returns:
reordered comment

main

public static void main(java.lang.String[] args)
Simple command line interface to CSVPack. Packs one csv file whose name is on the command line. Must have extension .csv
Use java com.mindprod.CSVPack somefile.csv

Parameters:
args - name of csv file to remove excess quotes and space