Ricebridge
Search This Site
Oct 07 2008 04:36 UTC

Got a question for us?
Just Ask!


$15 Gift Certificate for every bug you find.

  • Visa MasterCard
  • Visa Delta Laser
  • WorldPay

Bookmark Forum Topic for Ricebridge Java CSV Components at del.icio.us Digg Forum Topic for Ricebridge Java CSV Components at Digg.com Bookmark Forum Topic for Ricebridge Java CSV Components at reddit.com Bookmark Forum Topic for Ricebridge Java CSV Components at YahooMyWeb Bookmark Forum Topic for Ricebridge Java CSV Components at Spurl.net Bookmark Forum Topic for Ricebridge Java CSV Components at Simpy.com Bookmark Polyphasic Mutants at NewsVine Blink this Forum Topic for Ricebridge Java CSV Components at blinklist.com Bookmark Forum Topic for Ricebridge Java CSV Components at Furl.net Fark Forum Topic for Ricebridge Java CSV Components at Fark.com

Topic: Parse into a string array

Back to Topics (1 to 4 of 4) Posts RSS Feed
 
Is there any method which parse the csv file in to a string array...
for ex. if the csv file looks like
FID;TYP;TITEL;REIHE;HILFE;VORBELEGUNG 1.1;text;Questionnaire: Course
Evaluation;Title of course;; after parsing it should give
parse[0][0]=FID, parse[0][1]=TYP,...... parse[1][0]=1.1,
parse[1][0]=text,....
Ayyappan Chandrasekaran Jun 29 2005 11:37
The CsvManager.load(File) method returns a List of String[] objects.
You can easily convert this into a two dimensional String array.
Richard Rodger [Ricebridge Staff] Jun 29 2005 11:41
I tried but the problem is I'am able to parse the csv file only line by line not field by field. I checked with the code sample given in your site

package ricebridgecsv;

import java.lang.*;
import java.io.*;
import com.ricebridge.csvman.CsvManager;
import java.util.*;

public class Main {
public static void main(String[] args) {
Cover cov = new Cover();
CsvManager cm = new CsvManager();
List csvData = cm.load( "E:/StudienArbeit/csv/Afile.csv" );

for( int line = 0; line < csvData.size(); line++ ) {
String[] fields = (String[]) csvData.get(line);
System.out.println(fields[0] );
}
}

And the output I got is

FID;TYP;TITEL;REIHE;HILFE;VORBELEGUNG
1.1;text;Questionnaire: Course Evaluation;Title of course;;
1.2;typ1;Questionnaire: Course Evaluation;Type of course;;
1.3;text;Questionnaire: Course Evaluation;;;

Could you help me with some code samples to parse each field.
Ayyappan Chandrasekaran Jun 29 2005 13:10
Based on your example data, I think that you need to set the field
separator to be a ; character,
with the CsvManager.setSeparator(";") method. CSV Manager uses commas by
default, as explained in the documentation:
http://www.ricebridge.com/products/csvman/api/com/ricebridge/csvman/CsvSpec.html#setSeparator(java.lang.String)

The String array fields will than contain values fields[0], fields[1], etc., as you require.
Richard Rodger [Ricebridge Staff] Jun 29 2005 13:12
 
Show All (total: 4)




















comment on this page Home | Search | About Us | Contact Us | Our Products | Documentation | Resources | Login
Copyright © 2004-2008 Ricebridge. All Rights Reserved.