Package adams.data.io.input
Class SpreadSheetTimeseriesReader
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.io.input.AbstractDataContainerReader<Timeseries>
-
- adams.data.io.input.AbstractTimeseriesReader
-
- adams.data.io.input.SpreadSheetTimeseriesReader
-
- All Implemented Interfaces:
AdditionalInformationHandler
,CleanUpHandler
,Destroyable
,GlobalInfoSupporter
,FileFormatHandler
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,ShallowCopySupporter<AbstractDataContainerReader>
,SizeOfHandler
,MetaFileReader
,Serializable
,Comparable
public class SpreadSheetTimeseriesReader extends AbstractTimeseriesReader implements MetaFileReader
Reads timeseries containers from columns of a spreadsheet.
A new container is started, whenever the value of the ID column changes (hence you need to ensure that the data is ordered on this column).
However, it is not required to have an ID column present. In this case, all of the data gets added to the same timeseries.
Valid options are:
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-input <adams.core.io.PlaceholderFile> (property: input) The file to read and turn into a container. default: ${CWD}
-create-dummy-report <boolean> (property: createDummyReport) If true, then a dummy report is created if none present. default: false
-reader <adams.data.io.input.SpreadSheetReader> (property: reader) The reader to use for reading the spreadsheet file. default: adams.data.io.input.CsvSpreadSheetReader
-column-id <java.lang.String> (property: columnID) The name of the (optional) column containing the ID that distinguishes the timeseries. default: id
-column-timestamp <java.lang.String> (property: columnTimestamp) The name of the column containing the timestamp for a data point (accepted types: integer, date, time, datetime, timestamp). default: timestamp
-column-value <java.lang.String> (property: columnValue) The name of the column containing the value for a data point (accepted types: numeric). default: value
- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected String
m_ColumnID
the ID column.protected int
m_ColumnIDIndex
the ID column index.protected String
m_ColumnTimestamp
the timestamp column.protected int
m_ColumnTimestampIndex
the timestamp column type.protected String
m_ColumnValue
the value column.protected int
m_ColumnValueIndex
the value column index.protected SpreadSheetReader
m_Reader
the spreadsheet reader to use.protected int
m_RowIndex
the current row index.protected Timeseries
m_Timeseries
the current container.-
Fields inherited from class adams.data.io.input.AbstractDataContainerReader
m_CreateDummyReport, m_Input, m_InputIsFile, m_Processed, m_ReadData
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description SpreadSheetTimeseriesReader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
analyzeColumns(SpreadSheet sheet)
Analyzes the columns.String
columnIDTipText()
Returns the tip text for this property.String
columnTimestampTipText()
Returns the tip text for this property.String
columnValueTipText()
Returns the tip text for this property.void
defineOptions()
Adds options to the internal list of options.String[]
getActualFormatExtensions()
Returns the underlying format extensions.String
getColumnID()
Returns the name of the ID column.String
getColumnTimestamp()
Returns the name of the timestamp column.String
getColumnValue()
Returns the name of the value column.String
getFormatDescription()
Returns a string describing the format (used in the file chooser).String[]
getFormatExtensions()
Returns the extension(s) of the format.SpreadSheetReader
getReader()
Returns the reader to use.String
globalInfo()
Returns a string describing the object.protected void
performRead(SpreadSheet sheet)
Completes and returns the last timeseries that was started.protected void
readData()
Performs the actual reading.protected TimeseriesPoint
readDataPoint(SpreadSheet sheet)
Reads the next timeseries data point.String
readerTipText()
Returns the tip text for this property.protected void
reset()
Resets the scheme.void
setColumnID(String value)
Sets the name of the ID column.void
setColumnTimestamp(String value)
Sets the name of the timestamp column.void
setColumnValue(String value)
Sets the name of the value column.void
setReader(SpreadSheetReader value)
Sets the reader to use.-
Methods inherited from class adams.data.io.input.AbstractTimeseriesReader
getReaders
-
Methods inherited from class adams.data.io.input.AbstractDataContainerReader
checkData, cleanUp, compareTo, createDummyReport, createDummyReportTipText, destroy, doRead, equals, getAdditionalInformation, getCreateDummyReport, getDefaultFormatExtension, getInput, initialize, inputTipText, isInputFile, postProcessData, read, setCreateDummyReport, setInput, shallowCopy, shallowCopy
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Field Detail
-
m_Reader
protected SpreadSheetReader m_Reader
the spreadsheet reader to use.
-
m_ColumnID
protected String m_ColumnID
the ID column.
-
m_ColumnIDIndex
protected int m_ColumnIDIndex
the ID column index.
-
m_ColumnTimestamp
protected String m_ColumnTimestamp
the timestamp column.
-
m_ColumnTimestampIndex
protected int m_ColumnTimestampIndex
the timestamp column type.
-
m_ColumnValue
protected String m_ColumnValue
the value column.
-
m_ColumnValueIndex
protected int m_ColumnValueIndex
the value column index.
-
m_Timeseries
protected Timeseries m_Timeseries
the current container.
-
m_RowIndex
protected int m_RowIndex
the current row index.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceGlobalInfoSupporter
- Specified by:
globalInfo
in classAbstractOptionHandler
- Returns:
- a description suitable for displaying in the gui
-
getFormatDescription
public String getFormatDescription()
Returns a string describing the format (used in the file chooser).- Specified by:
getFormatDescription
in interfaceFileFormatHandler
- Specified by:
getFormatDescription
in classAbstractDataContainerReader<Timeseries>
- Returns:
- a description suitable for displaying in the file chooser
-
getFormatExtensions
public String[] getFormatExtensions()
Returns the extension(s) of the format.- Specified by:
getFormatExtensions
in interfaceFileFormatHandler
- Specified by:
getFormatExtensions
in classAbstractDataContainerReader<Timeseries>
- Returns:
- the extension (without the dot!)
-
getActualFormatExtensions
public String[] getActualFormatExtensions()
Returns the underlying format extensions.- Specified by:
getActualFormatExtensions
in interfaceMetaFileReader
- Returns:
- the format extensions (excluding dot)
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractDataContainerReader<Timeseries>
-
reset
protected void reset()
Resets the scheme.- Overrides:
reset
in classAbstractDataContainerReader<Timeseries>
-
setReader
public void setReader(SpreadSheetReader value)
Sets the reader to use.- Parameters:
value
- the reader
-
getReader
public SpreadSheetReader getReader()
Returns the reader to use.- Returns:
- the reader
-
readerTipText
public String readerTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setColumnID
public void setColumnID(String value)
Sets the name of the ID column.- Parameters:
value
- the column name
-
getColumnID
public String getColumnID()
Returns the name of the ID column.- Returns:
- the column name
-
columnIDTipText
public String columnIDTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setColumnTimestamp
public void setColumnTimestamp(String value)
Sets the name of the timestamp column.- Parameters:
value
- the column name
-
getColumnTimestamp
public String getColumnTimestamp()
Returns the name of the timestamp column.- Returns:
- the column name
-
columnTimestampTipText
public String columnTimestampTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setColumnValue
public void setColumnValue(String value)
Sets the name of the value column.- Parameters:
value
- the column name
-
getColumnValue
public String getColumnValue()
Returns the name of the value column.- Returns:
- the column name
-
columnValueTipText
public String columnValueTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
readDataPoint
protected TimeseriesPoint readDataPoint(SpreadSheet sheet) throws Exception
Reads the next timeseries data point.- Parameters:
sheet
- the current sheet- Returns:
- the next data point
- Throws:
Exception
- if reading of timeseries data fails
-
performRead
protected void performRead(SpreadSheet sheet) throws Exception
Completes and returns the last timeseries that was started.- Parameters:
sheet
- the current sheet- Throws:
Exception
- if reading of timeseries data fails
-
analyzeColumns
protected void analyzeColumns(SpreadSheet sheet) throws Exception
Analyzes the columns.- Parameters:
sheet
- the current sheet- Throws:
Exception
- if columns not present or of wrong type
-
readData
protected void readData()
Performs the actual reading.- Specified by:
readData
in classAbstractDataContainerReader<Timeseries>
-
-