Class CSVStore

All Implemented Interfaces:
PopupActivationListener, Serializable, Comparable, EventListener, ListSelectionListener, TableModel

public class CSVStore extends AttributeStore
This class enables reading a CSV file and accessing it through the AttributeStore interface.
See Also:
Serialized Form
  • Constructor Details

    • CSVStore

      public CSVStore(String filename) throws IOException
      Open a CSV file for readonly table access. Character data will be interpreted using the system default character set.
      Parameters:
      filename - The name of the file to open.
      Throws:
      IOException
    • CSVStore

      public CSVStore(String filename, String charset) throws IOException
      Open a CSV file for readonly table access.
      Parameters:
      filename - The name of the file to open.
      charset - The name of the character encoding set (code page) to use to interpret the character data in this file. If null will try to read the CPG file or use the default charset.
      Throws:
      IOException
  • Method Details

    • close

      public void close()
      Description copied from class: AttributeStore
      Close the table and release resources. The table should be used again after this method has been called.

      In many cases you do not need to call this method when you are finished using a table. Most tables will close automatically when they are no longer referenced.

      It is possible that this method will be deprecated or removed in a future release.

      Overrides:
      close in class AttributeStore
    • getFilename

      public String getFilename()
    • setColumnType

      public CSVStore setColumnType(String name, int type)
      Change the column type, in case the automatically inferred value is not correct.

      The type of a column is automatically inferred by scanning through records when the file is initially opened. If all of the values in a column are numeric, then a numeric type will be selected. However, sometimes it may be more appropriate to interpret columns as other types. For example, numbers with leading zeros that are significant may be better if interpreted as strings.

      The allowable data types are those listed in the AttributeFormat class, such as

      Parameters:
      name - the column name
      type - the new type to use
    • getRowCount

      public int getRowCount()
      Description copied from class: AttributeStore
      Get the number of rows in this store
      Specified by:
      getRowCount in interface TableModel
      Specified by:
      getRowCount in class AttributeStore
      Returns:
      the number of rows in this store
    • getYearForPeriod

      public int getYearForPeriod(int period)
      Description copied from class: AttributeStore
      Get the ending year for a given period.
      Specified by:
      getYearForPeriod in class AttributeStore
      Parameters:
      period - The period of interest
      Returns:
      the year for a given period
    • getPeriodCount

      public int getPeriodCount()
      Description copied from class: AttributeStore
      Get the total number of periods that this store supports
      Specified by:
      getPeriodCount in class AttributeStore
      Returns:
      The number of periods in this store
    • getValueAt

      public Object getValueAt(int row, int column, int period)
      Description copied from class: AttributeStore
      Get a cell value
      Specified by:
      getValueAt in class AttributeStore
      Parameters:
      row - The row containing the cell
      column - The column containing the cell
      period - The period of interest
      Returns:
      An object containing the cell value.
    • seek

      public void seek(long pos)
    • read

      public int read() throws IOException
      Throws:
      IOException