public class CSVFile
extends java.lang.Object
implements java.lang.Iterable<java.util.Vector<java.lang.Object>>
NOTE: By default, the numbers that are found in the CSV file are converted to Doubles. Use the load(boolean) method to control this, especially if you are using the fields later as the key in a Hashtable.
Modifier and Type | Field and Description |
---|---|
protected java.util.Vector<java.lang.Object> |
headerRecord
The header record, if there is one
|
protected boolean |
headersExist
Whether file has a line of column headers.
|
protected java.util.Vector<java.util.Vector<java.lang.Object>> |
infoRecords
The records of the CSV file
|
java.net.URL |
infoUrl
The location of the CSV file
|
Constructor and Description |
---|
CSVFile(java.lang.String name)
Don't do anything special, since all defaults are set already
|
CSVFile(java.net.URL url)
Don't do anything special, since all defaults are set already
|
Modifier and Type | Method and Description |
---|---|
int |
getNumberOfRecords() |
java.util.Vector<java.lang.Object> |
getRecord(int recordnumber)
Return a particular Vector representing the contents of a record line in
the CSV file.
|
boolean |
isHeadersExist()
Get whether the first line should be considered as headers to each column.
|
java.util.Iterator<java.util.Vector<java.lang.Object>> |
iterator()
Return an iterator, that can be used to traverse the records of the file.
|
void |
loadData()
Reads the numbers and stores them as Doubles.
|
void |
loadData(boolean readNumbersAsStrings)
Read the data in from the file, with the option of reading the numbers in
the files as strings.
|
void |
setHeadersExist(boolean set)
Set whether the first line should be considered as headers to each column.
|
public java.net.URL infoUrl
protected java.util.Vector<java.util.Vector<java.lang.Object>> infoRecords
protected java.util.Vector<java.lang.Object> headerRecord
protected boolean headersExist
public CSVFile(java.lang.String name) throws java.net.MalformedURLException
java.net.MalformedURLException
public CSVFile(java.net.URL url) throws java.net.MalformedURLException
java.net.MalformedURLException
public void setHeadersExist(boolean set)
public boolean isHeadersExist()
public void loadData()
public void loadData(boolean readNumbersAsStrings)
public int getNumberOfRecords()
public java.util.Vector<java.lang.Object> getRecord(int recordnumber)
recordnumber
- the number of the record in the csv file.public java.util.Iterator<java.util.Vector<java.lang.Object>> iterator()
iterator
in interface java.lang.Iterable<java.util.Vector<java.lang.Object>>
Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details