com.mindprod.csv
Class Lines2CSV
java.lang.Object
com.mindprod.csv.Lines2CSV
public final class Lines2CSV
- extends java.lang.Object
Converts text file of one field per line to a comma-separated CSV file.
Use: java.exe com.mindprod.Lines2CSV somefile.txt 3
How many lines should be grouped together on one line of the CSV file.
Output is somefile.csv. somefile.txt is left unchanged.
- Since:
- 2010-12-14
- Version:
- 1.0 2010-12-14 - initial version
- Author:
- Roedy Green, Canadian Mind Products
Constructor Summary |
Lines2CSV(java.io.File file,
int grouping,
char separatorChar,
char quoteChar,
char commentChar)
convert a txt file, constructor. |
Method Summary |
static void |
main(java.lang.String[] args)
Simple command line interface to Lines2CSV. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Lines2CSV
public Lines2CSV(java.io.File file,
int grouping,
char separatorChar,
char quoteChar,
char commentChar)
throws java.io.IOException
- convert a txt 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 for the output file. It is tab for the input file.
Note this is a 'char' not a "string".quoteChar
- character used to quote fields containing awkward chars.commentChar
- char to use to introduce comments. Use (char) 0 if none. Only one character allowed.
Note this is a 'char' not a "string". For output file. No comment presumed in input file.
- Throws:
java.io.IOException
- if problems reading/writing file
main
public static void main(java.lang.String[] args)
- Simple command line interface to Lines2CSV. P Converts text file of one field per line to a comma-separated CSV file.
java.exe com.mindprod.Lines2CSV somefile.txt 3
How many lines should be grouped together on one line of the CSV file.
Output is somefile.csv. somefile.txt is left unchanged.
You can use Lines2CSV constructor
in your own programs.
- Parameters:
args
- name of csv file to remove excess quotes and space