You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Brian Lee <br...@kldp.org> on 2002/01/27 04:50:13 UTC
Re: CSVParser Example?
It's a answer of my question.
I missed to call CSVParser.readColumnNames().
---
import java.io.*;
import org.apache.turbine.util.*;
class CSVExample
{
public static void main(String[] args) throws FileNotFoundException, IOException
{
TurbineConfig tc = new TurbineConfig(".","TurbineResources.properties");
tc.init();
if (args.length < 1)
{
System.out.print("Usage: java CSVExample <csvfile>");
System.exit(-1);
}
FileReader fr = new FileReader(args[0]);
CSVParser csvp = new CSVParser(fr);
csvp.readColumnNames();
while (csvp.hasNextRow())
{
ValueParser vp = csvp.nextRow();
System.out.println(vp.get("USER_ID"));
System.out.println(vp.get("FIRST_NAME"));
System.out.println(vp.get("LAST_NAME"));
}
}
}
---
ex.csv
---
USER_ID, FIRST_NAME, LAST_NAME
1, Foo, Bar
2, Spam, Eggs
---
On Fri, Dec 28, 2001 at 11:51:59AM +0900, brian@mail.kldp.org wrote:
> I'm using TDK 2.1 Release and wrote CSVParser example,
> but i met NullPointerException in DataStreamParser class.
>
> Is there any example of CSVParser?
>
> This is my example snippet.
>
> -----
> import java.io.*;
> import org.apache.turbine.util.*;
>
> class CSVExample
> {
> public static void main(String[] args) throws FileNotFoundException,
> IOException
> {
> FileReader fr = new FileReader(args[0]);
> CSVParser csvp = new CSVParser(fr);
>
> while (csvp.hasNextRow())
> {
> ValueParser vp = csvp.nextRow();
> System.out.println(vp.get("ID"));
> System.out.println(vp.get("NAME"));
> System.out.println(vp.get("PHONE"));
> System.out.println(vp.get("EMAIL"));
> }
> }
> }
> -----
> This is result of above example.
>
> -----
> Exception in thread "main" java.lang.NullPointerException
> at org.apache.turbine.util.DataStreamParser.nextRow(DataStreamParser.java:237)
> at CSVExample.main(CSVExample.java:13)
> -----
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Alternatives to hidden frames in Turbine framework?
Posted by Pat Saunders <ps...@comcen.com.au>.
G'day to all,
I am contemplating the best way to retrieve data from the server.
I have been mucking about using the "Pull model" and am very happy
with the clean manner in which I can get data from the server, and present
it inside the web page. When it comes to doing it dynamically, I have seen
it done with frames and basically it looks painful to code and maintain (and
many people on the net seem to agree).
I am curious as to how other bods do it in the context of Turbine/Pull/Push
model that
improves in some way on using frames (which really is a hack as far as I'm
concerned).
I have read on article at
http://www.onjava.com/pub/a/onjava/2002/01/23/javascript.html?page=1
and it certainly appears to offer an alternative that can be wrapped in a
Velocity Macro, or other templating tool.
If people can point me to other tools/techniques that would be much
appreciated,
Thanks,
Patrick.
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>