TableView/Parsing csv
From: Gilbert Rebhan (mailforgilbert_at_gmx.de)
Date: 04/25/04
- Next message: Christophe Vanfleteren: "Re: TableView/Parsing csv"
- Previous message: Roedy Green: "Re: TextArea with \n"
- Next in thread: Christophe Vanfleteren: "Re: TableView/Parsing csv"
- Reply: Christophe Vanfleteren: "Re: TableView/Parsing csv"
- Reply: Roedy Green: "Re: TableView/Parsing csv"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 25 Apr 2004 10:31:38 +0200
Hi,
i've written a plugin for eclipse that provides a tableview,
reading a csvfile.
til now the csvfile had always the format =
String|String
String|String
... with 2 Strings on every line, no blanks
but now the writing of the csvfiles has changed, so
lines like =
String|blank
or
blank|String
... may appear
Now my sorting get's cluttered :(
My ViewContentProvider has the following method =
--------------------------
class ViewContentProvider implements IStructuredContentProvider
{
protected Vector csvdata;
public final static int NB_COLUMNS = 2;
public void initVectors(String csvfile)
{
String aLine;
csvdata = new Vector();
Vector row = new Vector();
try
{
if (csvfile != null)
{
FileInputStream fin = new
FileInputStream(csvfile);
BufferedReader br = new BufferedReader(new
InputStreamReader(fin));
// extract csvdata
while ((aLine = br.readLine()) != null)
{
StringTokenizer st = new StringTokenizer(aLine, "|");
while (st.hasMoreTokens())
{
row.add(st.nextToken());
if (row.size() == NB_COLUMNS)
{
csvdata.add(row);
row = new Vector();
}
}
}
if (!row.isEmpty())
csvdata.add(row);
br.close();
}
} catch (Exception e)
{
e.printStackTrace();
}
---------------------------
Question =
i want to skip those lines containing only one field,
simply ignore them, how to filter them out ?
I use jdk 1.3.1_03, so no regexp
Thanks for any hints!!
bye4now, Gilbert
- Next message: Christophe Vanfleteren: "Re: TableView/Parsing csv"
- Previous message: Roedy Green: "Re: TextArea with \n"
- Next in thread: Christophe Vanfleteren: "Re: TableView/Parsing csv"
- Reply: Christophe Vanfleteren: "Re: TableView/Parsing csv"
- Reply: Roedy Green: "Re: TableView/Parsing csv"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]