| java.lang.Object com.knowgate.misc.CSVParser
CSVParser | public class CSVParser (Code) | | Delimited Text Parser
Parses a delimited text file into a memory array
author: Sergio Montoro Ten version: 3.0 |
Method Summary | |
public String | charSet() | public void | charSet(String sCharSetName) | public int | errorLine() | public int | find(int iCol, String sVal) | public int | findi(int iCol, String sVal) | public int | getColumnCount() | public int | getColumnPosition(String sColumnName) | public char | getDelimiter() | public String | getField(int iCol, int iRow) Get value for a field at a given row and column.
Column indexes are zero based.
Row indexes range from 0 to getLineCount()-1. | public String | getField(String sCol, int iRow) | public String | getLine(int iLine) Get line from a parsed file.
Lines are delimited by the Line Feed (LF, CHAR(10), '\n') character
Parameters: iLine - Line Number [0..getLineCount()-1] Full Text for Line. | public int | getLineCount() | public void | parseData(char[] aCharData, String sFileDescriptor) Parse data from a character array
Parsed values are stored at an internal array in this CSVParser.
Parameters: sFileDescriptor - A list of column names separated by ',' ';' '|' '`' or '\t'.Column names may be quoted. | public void | parseFile(File oFile, String sFileDescriptor) Parse a delimited text file
Parsed values are stored at an internal array in this CSVParser.
File is readed using the character set specifid at constructor
Parameters: oFile - CSV File Parameters: sFileDescriptor - A list of column names separated by ',' ';' '|' '`' or '\t'.Column names may be quoted. | public void | parseFile(String sFilePath, String sFileDescriptor) Parse a delimited text file
Parsed values are stored at an internal array in this CSVParser.
Parameters: sFilePath - File Path Parameters: sFileDescriptor - A list of column names separated by ',' ';' '|' '`' or '\t'.Column names may be quoted. | public void | writeToFile(String sFilePath) | public void | writeToStream(OutputStream oStrm) |
CSVParser | public CSVParser()(Code) | | |
CSVParser | public CSVParser(String sCharSetName)(Code) | | Create CSV Parser and set encoding to be used
Parameters: sCharSetName - Name of charset encoding |
errorLine | public int errorLine()(Code) | | |
getColumnCount | public int getColumnCount()(Code) | | Get column count
int since: 3.0 |
getColumnPosition | public int getColumnPosition(String sColumnName)(Code) | | Parameters: sColumnName - Column Name Zero based index for column position or -1 if column was not found. |
getDelimiter | public char getDelimiter()(Code) | | |
getLineCount | public int getLineCount()(Code) | | Get line count
int since: 3.0 |
parseData | public void parseData(char[] aCharData, String sFileDescriptor) throws ArrayIndexOutOfBoundsException, RuntimeException, NullPointerException, IllegalArgumentException(Code) | | Parse data from a character array
Parsed values are stored at an internal array in this CSVParser.
Parameters: sFileDescriptor - A list of column names separated by ',' ';' '|' '`' or '\t'.Column names may be quoted. Lines are delimiter by '\n' characters Example 1) tx_mail,tx_name,tx_surname Example 2) "tx_name","tx_surname","tx_salutation"
throws: ArrayIndexOutOfBoundsException - Delimited values for a file is greaterthan columns specified at descriptor. throws: RuntimeException - If delimiter is not one of { ',' ';' '|' '`' or '\t' } throws: NullPointerException - if sFileDescriptor is null throws: IllegalArgumentException - if sFileDescriptor is "" |
parseFile | public void parseFile(File oFile, String sFileDescriptor) throws ArrayIndexOutOfBoundsException, IOException, FileNotFoundException, RuntimeException, NullPointerException, IllegalArgumentException, UnsupportedEncodingException(Code) | | Parse a delimited text file
Parsed values are stored at an internal array in this CSVParser.
File is readed using the character set specifid at constructor
Parameters: oFile - CSV File Parameters: sFileDescriptor - A list of column names separated by ',' ';' '|' '`' or '\t'.Column names may be quoted. Lines are delimiter by '\n' characters Example 1) tx_mail,tx_name,tx_surname Example 2) "tx_name","tx_surname","tx_salutation"
throws: IOException - throws: FileNotFoundException - throws: ArrayIndexOutOfBoundsException - Delimited values for a file is greaterthan columns specified at descriptor. throws: RuntimeException - If delimiter is not one of { ',' ';' '|' '`' or '\t' } throws: NullPointerException - if oFile or sFileDescriptor are null throws: IllegalArgumentException - if sFileDescriptor is "" throws: UnsupportedEncodingException - since: 3.0 |
parseFile | public void parseFile(String sFilePath, String sFileDescriptor) throws ArrayIndexOutOfBoundsException, IOException, FileNotFoundException, RuntimeException, NullPointerException, IllegalArgumentException, UnsupportedEncodingException(Code) | | Parse a delimited text file
Parsed values are stored at an internal array in this CSVParser.
Parameters: sFilePath - File Path Parameters: sFileDescriptor - A list of column names separated by ',' ';' '|' '`' or '\t'.Column names may be quoted. Lines are delimiter by '\n' characters Example 1) tx_mail,tx_name,tx_surname Example 2) "tx_name","tx_surname","tx_salutation"
throws: IOException - throws: FileNotFoundException - throws: ArrayIndexOutOfBoundsException - Delimited values for a file is greaterthan columns specified at descriptor. throws: RuntimeException - If delimiter is not one of { ',' ';' '|' '`' or '\t' } throws: NullPointerException - if oFile or sFileDescriptor are null throws: IllegalArgumentException - if sFileDescriptor is "" throws: UnsupportedEncodingException - |
|
|