Re: [OT] How to load a csv file into java
Lesson: I/O: Reading and Writing (but no 'rithmetic) http://java.sun.com/docs/books/tutorial/essential/io/ -Dennis Richard Reyes [EMAIL PROTECTED] 08/19/2005 12:01 PM Please respond to Struts Users Mailing List user@struts.apache.org To Struts Users Mailing List user@struts.apache.org cc Subject [OT] How to load a csv file into java Hi Guys, I need to load exported information ( csv file ) into POJOs. How do I do this? Thanks Richard - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [OT] How to load a csv file into java
Hi Richard, I need to load exported information ( csv file ) into POJOs. How do I do this? Well, just use the html:file/ tag (and don't forget tu use the correct attributes in your html:form/ tag). Then converting your CSV file'll only be a matter of split()ing the resulting data... Well, more or less ;-) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [OT] How to load a csv file into java
Hi All, Thanks for the response. I think I can use this... http://ostermiller.org/utils/CSV.html What do guys think? On 8/20/05, Stéphane Zuckerman [EMAIL PROTECTED] wrote: Hi Richard, I need to load exported information ( csv file ) into POJOs. How do I do this? Well, just use the html:file/ tag (and don't forget tu use the correct attributes in your html:form/ tag). Then converting your CSV file'll only be a matter of split()ing the resulting data... Well, more or less ;-) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [OT] How to load a csv file into java
From: Richard Reyes [EMAIL PROTECTED] I need to load exported information ( csv file ) into POJOs. How do I do this? Check the archives of commons-user and commons-dev; there have been recent discussions about a Jakarta Commons CSV component. There were links to several existing libraries, one of which I think might be coming through the incubator. At least, I think I remember someone mentioning writing a proposal, though I'm not sure how far it's gotten. One of those links will probably be something you can use. -- Wendy Smoak - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [OT] How to load a csv file into java
At 12:12 AM +0800 8/20/05, Richard Reyes wrote: Hi All, Thanks for the response. I think I can use this... http://ostermiller.org/utils/CSV.html I've had good results with this library. Despite what some posters have indicated, if you're talking about true CSV as exported from Excel, for example, it's not as simple as splitting on commas. There are rules about quoted values and the case of empty columns which make reading in CSV hard enough that there's no reason to reinvent the wheel when Mr. Ostermiller has gone to so much trouble. The only issue would be if you can't deal with the GPL license. As long as you're not planning on redistributing your app, that's unlikely to be an issue. Joe What do guys think? On 8/20/05, Stéphane Zuckerman [EMAIL PROTECTED] wrote: Hi Richard, I need to load exported information ( csv file ) into POJOs. How do I do this? Well, just use the html:file/ tag (and don't forget tu use the correct attributes in your html:form/ tag). Then converting your CSV file'll only be a matter of split()ing the resulting data... Well, more or less ;-) - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Joe Germuska [EMAIL PROTECTED] http://blog.germuska.com Narrow minds are weapons made for mass destruction -The Ex - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [OT] How to load a csv file into java
Richard Reyes wrote: Hi All, Thanks for the response. I think I can use this... http://ostermiller.org/utils/CSV.html It mostly works; I vaguely recall having to tweak it a bit, but nothing serious. Dave - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: [OT] How to load a csv file into java
Parsing CSV files in 5 minutes or less! CsvJdbc - a JDBC driver for CSV files Rocks! I was looking for an utility which can read and parse the CSV files. The open source utility CsvJdbc was perfect for my requirements. It parses the given CSV file with no problem. Just include the csvjdbc.jar in the classpath and start using the API. The command line argument is C:\\test (Java requires the escape character \ for the \, which is the separator). The filename is anything.csv and is stored in the directory specified above. Version is Version 0.10. The documentation says : The driver also now supports scrollable result sets. This following example code shows how these are used. ... Connection conn = Drivermanager.getConnection(jdbc:relique:csv: + args[0],props) Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, 0); ResultSet results = stmt.executeQuery(SELECT ID,NAME FROM sample); resulst.next(); ... results.first(); ... results.previous(); ... results.relative(2); ... results.absolute(2); ... But it looks like it is not implemented yet. I got : Oops- java.lang.UnsupportedOperationException: ResultSet.relative() unsupported error message. Here is the modified example program that I am using for my purposes: /* * Created on Dec 16, 2004 * @author BXParanj */ import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; public class RegistrationParser { private String userName; private String password; public RegistrationParser(String fileName) { } public static void main(String[] args) { String index = fcgp001; try { // load the driver into memory Class.forName(org.relique.jdbc.csv.CsvDriver); // create a connection. The first command line parameter is assumed to // be the directory in which the .csv files are held Connection conn = DriverManager.getConnection(jdbc:relique:csv: + args[0] ); // create a Statement object to execute the query with Statement stmt = conn.createStatement(); // Select the EBK_USERNAME and EBK_PASSWORD columns from lead.csv file String sqlQuery = SELECT EBK_USERNAME, EBK_PASSWORD FROM lead WHERE EBK_USERNAME = + index ; ResultSet results = stmt.executeQuery(sqlQuery); // dump out the results while (results.next()) { System.out.println(EBK_USERNAME= + results.getString(EBK_USERNAME) + EBK_PASSWORD= + results.getString(EBK_PASSWORD)); } // clean up results.close(); stmt.close(); conn.close(); } catch(Exception e) { System.out.println(Oops- + e); } } } -Original Message- From: Richard Reyes [mailto:[EMAIL PROTECTED] Sent: Friday, August 19, 2005 12:02 PM To: Struts Users Mailing List Subject: [OT] How to load a csv file into java Hi Guys, I need to load exported information ( csv file ) into POJOs. How do I do this? Thanks Richard - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]