Ricebridge
Search This Site
Sep 02 2010 23:16 UTC


$15 Gift Certificate for every bug you find.

MaxMind GeoIP
This IP address to country database is provided as a CSV file that can easily be read by CSV Manager.

Got a question for us?
Just Ask!

Bookmark TableModel features description for Ricebridge Java CSV Manager Component at del.icio.us Digg TableModel features description for Ricebridge Java CSV Manager Component at Digg.com Bookmark TableModel features description for Ricebridge Java CSV Manager Component at reddit.com Bookmark TableModel features description for Ricebridge Java CSV Manager Component at YahooMyWeb Bookmark TableModel features description for Ricebridge Java CSV Manager Component at Spurl.net Bookmark TableModel features description for Ricebridge Java CSV Manager Component at Simpy.com Bookmark Polyphasic Mutants at NewsVine Blink this TableModel features description for Ricebridge Java CSV Manager Component at blinklist.com Bookmark TableModel features description for Ricebridge Java CSV Manager Component at Furl.net Fark TableModel features description for Ricebridge Java CSV Manager Component at Fark.com

TableModel Data

CSV Manager can load and save your data as a Swing TableModel.

Code Example

File       csvfile  = new File("mydata.csv");
CsvManager csvman   = new CsvManager();
csvman.getCsvSpec().setProperty( "TableModel.dataHasHeaders", true );
TableModel tm       = csvman.loadTableModel( csvfile );
JTable     table    = new JTable();
table.setModel( tm );

This code example loads the data in a CSV file into an object which implements the TableModel interface.

Use this method when...

  • you want all the data in memory.
  • your data has standard columns.
  • you need to pass the CSV data to code that already uses TableModels.
  • you want to present your data visually.
The loadTableModel method can take a String containing the file path, or a File object. It also takes an additional boolean parameter telling it whether to expect column headers at the top of the CSV file or not.

What happens when some rows contain more fields than others?

The number of columns in the TableModel expands to the maximum number of data fields found in any one row. This means that all data is included in the TableModel. In the normal case for a well-formatted CSV file, the number of columns is determined by the number of headers in the first row.

What happens when some rows are missing fields?

When a table row contains fewer cells that the column count for the table, CSV Manager returns empty strings as the cell value. This means that the table remains valid even when rows in the CSV file are missing data fields.

OK, how do I get the column headers?

CSV Manager also implements the getColumnName TableModel method, and this returns the name of the specified column. The headers are assumed to be in the first line of the CSV file. If the column names are not in the first line, then they are either in a predefined line (say line 3), so start loading lines from there using setStartLine, or you can set CSV Manager to ignore empty lines, until you find them.

But my data isn't in a file!

You are not restricted to loading CSV data only from files. You can also load data from Strings (loadFromString(String) method) and from InputStreams (load(InputStream) method). This means that you can use CSV Manager in a completely dynamic way within your application.

What about saving data to a CSV file?

You can also save data to a CSV file using a TableModel. Use the getModel method of JTable, to get the TableModel object from your JTable object, then hand it over to CsvManager to save as a CSV file. Here's the example code:

File       csvfile = new File("mydata.csv");
CsvManager csvman  = new CsvManager();

JTable myJTable 
  = new JTable( 
      new Object[][] { { "1", "one" }, 
                       { "2", "two" }, 
                       { "3", "three" } },
      new Object[] { "Number", "Name" } );

TableModel tm = myJTable.getModel();
csvman.saveTableModel( csvfile, tm );

CSV Manager uses the TableModel to output column headers. See the save method description for more details.

What other data structures can you handle?

We also support:

I need to see something working.

Sure, no problem. Head on over to our online demo and try out CSV Manager on your own data.

I have another question...

If you have a particular question you need answered, just ask! We're happy to explain exactly how CSV Manager works and show you how to use it.

FREE Email Support

All CSV Manager licenses include a FREE 6 month Email Support Package, worth $1500.00.

Email Support Package

FREE XML Manager

All CSV Manager licenses include a FREE XML Manager single developer license, worth $170.00.

Convert CSV to XML

Any CSV Format

The CSV Manager component can handle any style of tabular text data, from Excel CSV files to the UNIX passwd file.

CSV Formats

"Your product actually did help a lot! I was able to accelerate my development time quite a bit and your service support was also real nice."
Luis Garcia,
Independent Contractor
"An event-based CSV parser is so much more flexible and elegant than the free alternatives that I found. We use it for applications which require a mixture of XML and CSV data. This requires a parser that performs well, uses memory efficiently, simplifies data access and accurately formats output data. We found the Ricebridge parser easy to work with, conspicuously well documented and capable of handling large (500kb+) files. That's a big thumbs up from all the Gaisan team."
Shane Dempsey,
Gaisan
"I would have spent all day trying to read CSV fields that contained commas. I bought your software about 15 minutes ago and my problem is ALREADY solved. Thank you very, very much for a quality piece of software."
Adrian Klingel,
Illumaware
"Ricebridge CSV Manager was really easy to integrate into our existing system, and has been completely reliable for data transfer, not to mention a big time saver!"
Fred Crowe, Speech-Writers
comment on this page Home | Search | About Us | Contact Us | Our Products | Documentation | Resources | Login
Copyright © 2004-2010 Ricebridge. All Rights Reserved.