Ricebridge
Search This Site
Jul 29 2010 17:00 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 Streaming Data feature description for Ricebridge Java CSV Manager Component at del.icio.us Digg Streaming Data feature description for Ricebridge Java CSV Manager Component at Digg.com Bookmark Streaming Data feature description for Ricebridge Java CSV Manager Component at reddit.com Bookmark Streaming Data feature description for Ricebridge Java CSV Manager Component at YahooMyWeb Bookmark Streaming Data feature description for Ricebridge Java CSV Manager Component at Spurl.net Bookmark Streaming Data feature description for Ricebridge Java CSV Manager Component at Simpy.com Bookmark Polyphasic Mutants at NewsVine Blink this Streaming Data feature description for Ricebridge Java CSV Manager Component at blinklist.com Bookmark Streaming Data feature description for Ricebridge Java CSV Manager Component at Furl.net Fark Streaming Data feature description for Ricebridge Java CSV Manager Component at Fark.com

Streaming Data

CSV Manager can load and save your data in a continuous stream. This allows you to handle very large CSV files.

Code Example

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

loader.begin();
while( loader.hasNext() ) {
  String[] fields = loader.next();

  for( int field = 0; field < fields.length; field++ ) {
    System.out.print( fields[field]+", " );
  }
  System.out.println();
}
loader.end();

This code example can load data from a very large CSV file one line at a time. This means that the whole file is not loaded in memory which conserves resources and makes the loading process a lot faster. All you have to do is call the CsvManager.makeLoader method. This returns a CsvLoader object that you can use to pull the CSV data in, one line at a time.

Use this method when...

  • you cannot load all the data into memory at once.
  • you want to handle the data line-by-line.
  • You need to control exactly when you get the next line of data.
The makeLoader method can take a String containing the file path, a File object.

What happens when some rows contain more fields than others?

Each data row is returned individually as a String[] array by the CsvLoader object. Each array always contains enough elements to hold all the data fields found in any one row, so you never lose data.

What happens when some rows are missing fields?

The String[] array returned by CsvLoader always contains a minimum number of elements. This minimum can be set using the setNumFields method. If not set, the number of fields in the first line is used as the minimum. This minimum is automatically increased (and stays increased) whenever a row containing more fields than the previous minimum is found. For any given line, if the number of data fields is less than the minimum, then the remaining fields are set to empty strings.

OK, how do I get the column headers?

The column headers are simply the first row of data returned. 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. The CsvManager.makeLoader method also accepts standard Java InputStreams and Readers. You can also load CSV data direct from in-memory Strings by using a Text object.

What about saving data to a CSV file?

You can also save data to a CSV file one line at a time by calling the CsvManager.makeSaver method. This returns a CsvSaver object that you can use to push CSV data out, one line at a time. Here's the example code:

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

ArrayList data = new ArrayList();
data.add( new String[] {"1","a","AA"} );
data.add( new String[] {"2","b","BB"} );

saver.begin();
for( Iterator lineI = data.iterator(); lineI.hasNext(); ) {
  String[] fields = (String[]) lineI.next();
  saver.next( fields );
}
saver.end();

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.