com.mindprod.csv
Class CSVTuple
java.lang.Object
com.mindprod.csv.CSVTuple
public final class CSVTuple
- extends java.lang.Object
Break up a long CSV line into several shorter ones.
Use: java.exe com.mindprod.CSVTuple somefile.csv 4
Number is how many fields you want in each output line.
Will lake a file like this:
a,b,c,d,e,f
and produce
a,b,c,d
a,b,c,e
a,b,c,f
Short lines are padded out to tuple fields with empty fields.
x,y
becomes
x,y,,,
- Since:
- 2011-01-22
- Version:
- 1.1 2010-12-24 allow you to specify encoding
- Author:
- Roedy Green, Canadian Mind Products
Constructor Summary |
CSVTuple(java.io.File file,
char separatorChar,
char quoteChar,
char commentChar,
int tupleLength,
java.lang.String encoding)
break a CSV file into tuples, constructor. |
Method Summary |
static void |
main(java.lang.String[] args)
Simple command line interface to CSVTuple to brake a csv file into fixed length tuples. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
CSVTuple
public CSVTuple(java.io.File file,
char separatorChar,
char quoteChar,
char commentChar,
int tupleLength,
java.lang.String encoding)
throws java.io.IOException
- break a CSV file into tuples, constructor. Just create the 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.tupleLength
- how many fields you want in each output record.encoding
- encoding of input and output.
- Throws:
java.io.IOException
- if problems reading/writing file
main
public static void main(java.lang.String[] args)
- Simple command line interface to CSVTuple to brake a csv file into fixed length tuples.
Name of file appears on the command line
followed by the desired length in fields of the fixed length tuples. Must have
extension .csv
Use java com.mindprod.CSVTuple somefile.csv 4
Output replaces input. If you want the input, make a copy first.
- Parameters:
args
- name of csv file r followed the desired length in fields of the fixed length tuples