com.mindprod.csv
Class CSVPatch

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

public final class CSVPatch
extends java.lang.Object

patch a CSV file with a list of from:to pairs.

Use: java.exe com.mindprod.CSVPatch somefile.csv fromto.csv 0 3 (columns to patch) Typically used to update URLs in a column with recently discovered replacements.

Since:
2010-12-30
Version:
1.2 2011-03-08 eliminate all but first duplicate in patch file. allow comments in patch file, allow 2+ cols in patch file.
Author:
Roedy Green, Canadian Mind Products

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

Constructor Detail

CSVPatch

public CSVPatch(java.io.File fileToPatch,
                java.io.File fileOfPairs,
                char separatorChar,
                char quoteChar,
                char commentChar,
                java.lang.String encoding,
                int... colsToPatch)
         throws java.io.IOException
patch a CSV fileToPatch, constructor. Just create. There are no methods to call.

Parameters:
fileToPatch - CSV fileToPatch to be packed to remove excess space and quotes.
fileOfPairs - CSV file of pairs from,to (extra cols ignored)
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.
colsToPatch - list of columns that should be patched, 0-based.
Throws:
java.io.IOException - if problems reading/writing fileToPatch
Method Detail

main

public static void main(java.lang.String[] args)
Simple command line interface to CSVPatch. Patches one csv file whose name is on the command line with a list of from to pairs in another csv file. You specify which columns to translate from to to. Both files must have the extension .csv

Parameters:
args - name of csv file to patch, from-to pairs file, columns to patch.