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<DataContainerReader>,SizeOfHandler,DataContainerReader<Timeseries>,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 Stringm_ColumnIDthe ID column.protected intm_ColumnIDIndexthe ID column index.protected Stringm_ColumnTimestampthe timestamp column.protected intm_ColumnTimestampIndexthe timestamp column type.protected Stringm_ColumnValuethe value column.protected intm_ColumnValueIndexthe value column index.protected SpreadSheetReaderm_Readerthe spreadsheet reader to use.protected intm_RowIndexthe current row index.protected Timeseriesm_Timeseriesthe 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 voidanalyzeColumns(SpreadSheet sheet)Analyzes the columns.StringcolumnIDTipText()Returns the tip text for this property.StringcolumnTimestampTipText()Returns the tip text for this property.StringcolumnValueTipText()Returns the tip text for this property.voiddefineOptions()Adds options to the internal list of options.String[]getActualFormatExtensions()Returns the underlying format extensions.StringgetColumnID()Returns the name of the ID column.StringgetColumnTimestamp()Returns the name of the timestamp column.StringgetColumnValue()Returns the name of the value column.StringgetFormatDescription()Returns a string describing the format (used in the file chooser).String[]getFormatExtensions()Returns the extension(s) of the format.SpreadSheetReadergetReader()Returns the reader to use.StringglobalInfo()Returns a string describing the object.protected voidperformRead(SpreadSheet sheet)Completes and returns the last timeseries that was started.protected voidreadData()Performs the actual reading.protected TimeseriesPointreadDataPoint(SpreadSheet sheet)Reads the next timeseries data point.StringreaderTipText()Returns the tip text for this property.protected voidreset()Resets the scheme.voidsetColumnID(String value)Sets the name of the ID column.voidsetColumnTimestamp(String value)Sets the name of the timestamp column.voidsetColumnValue(String value)Sets the name of the value column.voidsetReader(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
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager, toCommandLine
-
-
-
-
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:
globalInfoin interfaceGlobalInfoSupporter- Specified by:
globalInfoin 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:
getFormatDescriptionin interfaceFileFormatHandler- Specified by:
getFormatDescriptionin 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:
getFormatExtensionsin interfaceFileFormatHandler- Specified by:
getFormatExtensionsin classAbstractDataContainerReader<Timeseries>- Returns:
- the extension (without the dot!)
-
getActualFormatExtensions
public String[] getActualFormatExtensions()
Returns the underlying format extensions.- Specified by:
getActualFormatExtensionsin interfaceMetaFileReader- Returns:
- the format extensions (excluding dot)
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractDataContainerReader<Timeseries>
-
reset
protected void reset()
Resets the scheme.- Overrides:
resetin 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:
readDatain classAbstractDataContainerReader<Timeseries>
-
-