Blank results of get(String arg0)

20 views
Skip to first unread message

Fenomen

unread,
Nov 30, 2011, 6:06:55 AM11/30/11
to CSVChat
Hi,

I've got some strange problem with the CSV Reader. When I try to read
data from file, the method get(String arg0) return blank ("") String
instead of expected value.

I do it in following way:

try {
reader = new CsvReader(path);
reader.getHeaders();
while (reader.readRecord()) {
...myField = reader.get("NameOfSomeColumnInMyCSVFile")
}
catch (Exception e) {
e.printStackTrace();
}

And myField is blank - other words, when I would like to get the value
of myField, I get empty string ("")

What is more confusing, I used that library for other csv files and
everything went ok; So i wondered, whether there is some diffirence
between working- and non-working file, but I haven't found any.

Could you suggest me any ideas, what could be wrong?

shriop

unread,
Nov 30, 2011, 7:13:55 AM11/30/11
to CSVChat
You're calling getHeaders() at the beginning when you want to be
calling readHeaders(). getHeaders is a property accessor method that
returns the headers as an array of strings. readHeaders is the method
that will read a line of data as a header line ad initialize the
header array.

Bruce Dunwiddie

Fenomen

unread,
Dec 1, 2011, 8:31:02 AM12/1/11
to CSVChat
Yeah, I found the solution on my own.
Just the same, thanks for message.
Reply all
Reply to author
Forward
0 new messages