you have to parse your csv line into multiple strings.... columns

take a look at SuperCSV, a handy library for handling csv files in java

g,
kris




"Eldred Mullany" <eldred.mull...@easypay.co.za> 
10.02.2010 13:44
Bitte antworten an
"Tapestry users" <users@tapestry.apache.org>


An
"Tapestry users" <users@tapestry.apache.org>
Kopie

Thema
RE: Reading a .csv file and displaying grid table of it







Ahh no formatting allowed. The .csv table is 3 columns and 8 rows. The
grid displays 8 rows but one column ? 

Thanks 

-----Original Message-----
From: Eldred Mullany 
Sent: 10 February 2010 02:37 PM
To: Tapestry users
Subject: Reading a .csv file and displaying grid table of it

Hi everyone 

 

I am attempting to read a .csv file from a directory, however I am not
sure what I am doing wrong here. I am using a BufferedReader to read the
file. Then I am looping through using the readLine() method and
assigning each line to an ArrayList, well I thought it was as simple as
that :-( 

 

When my .tml file loads it displays the grid table incorrectly, so I am
assuming that my object (arrayList) is wrong. 

 

Here is my EventLink method which reads the file and assigns it to an
arrayList. 

 

....

@Property

private List newStores;

 

....

 

Object onProcess() {

      File file = new File(getAbsolutePath(this.url));

      this.newStores = new ArrayList();

 

      if (file.canRead()) {

          try {

            // Construct the BufferedReader object

            this.bufferedReader = new BufferedReader(new
FileReader(getAbsolutePath(this.url)));

            String line = null;

 

            while ((line = bufferedReader.readLine()) != null) {

                this.newStores.add(line);

            }// end of while

          } catch (IOException ex) {

            ex.printStackTrace();

          } finally {

            // Close the BufferedReader

            try {

                if (this.bufferedReader != null)

                  this.bufferedReader.close();

            } catch (IOException ex) {

                ex.printStackTrace();

            }

          }

      }

 

      this.result = !this.result;

      return this.zone;

    }

 

  public String getAbsolutePath(String context) {

      String url = globals.getServletContext().getRealPath(context);

      return url;

    }

 

 

My grid component displays a header called empty and one column with 8
rows showing false. Like the example below. 

 

Empty

false

false

false

false

false

false

 

 

 

 

...and here is the format of my .csv file in excel would look like: 

 

StoreName

Store code

Card acceptor id

Row 1

1234

123

Row 2

1235

234

Row 3

1234

432

Row 4 

3453

222

Row 5

234

234

Row 6

4455

3445

Row 7

3445

444

Row 8 

4558

222

 

 

Thanking you in advance ! 

Regards Eldred 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org


Reply via email to