com.holub.database
Class CSVImporter
java.lang.Object
com.holub.database.CSVImporter
- All Implemented Interfaces:
- Table.Importer
public class CSVImporter
- extends Object
- implements Table.Importer
Pass this importer to a Table
constructor (such
as
{link com.holub.database.ConcreteTable#ConcreteTable(Table.Importer)}
to initialize
a Table
from
a comma-sparated-value repressentation. For example:
Reader in = new FileReader( "people.csv" );
people = new ConcreteTable( new CSVImporter(in) );
in.close();
The input file for a table called "name" with
columns "first," "last," and "addrId" would look
like this:
name
first, last, addrId
Fred, Flintstone, 1
Wilma, Flintstone, 1
Allen, Holub, 0
The first line is the table name, the second line
identifies the columns, and the subsequent lines define
the rows.
- See Also:
Table
,
Table.Importer
,
CSVExporter
©2004 Allen I. Holub. All rights reserved.
This code may be used freely by yourself with the following restrictions:
- Your splash screen, about box, or equivalent, must include
Allen Holub's name, copyright, and URL. For example:
This program contains Allen Holub's SQL package.
(c) 2005 Allen I. Holub. All Rights Reserved.
http://www.holub.com
If your program does not run interactively, then the foregoing
notice must appear in your documentation.
- You may not redistribute (or mirror) the source code.
- You must report any bugs that you find to me. Use the form at
http://www.holub.com/company/contact.html
or send email.
- The software is supplied as is. Neither Allen Holub nor
Holub Associates are responsible for any bugs (or any problems
caused by bugs, including lost productivity or data)
in any of this code.
|
CSVImporter
public CSVImporter(Reader in)
startTable
public void startTable()
throws IOException
- Specified by:
startTable
in interface Table.Importer
- Throws:
IOException
loadTableName
public String loadTableName()
throws IOException
- Specified by:
loadTableName
in interface Table.Importer
- Throws:
IOException
loadWidth
public int loadWidth()
throws IOException
- Specified by:
loadWidth
in interface Table.Importer
- Throws:
IOException
loadColumnNames
public Iterator loadColumnNames()
throws IOException
- Specified by:
loadColumnNames
in interface Table.Importer
- Throws:
IOException
loadRow
public Iterator loadRow()
throws IOException
- Specified by:
loadRow
in interface Table.Importer
- Throws:
IOException
endTable
public void endTable()
throws IOException
- Specified by:
endTable
in interface Table.Importer
- Throws:
IOException