Package weka.core.converters
Class SpreadSheetLoader
- java.lang.Object
-
- weka.core.converters.AbstractLoader
-
- weka.core.converters.AbstractFileLoader
-
- weka.core.converters.SpreadSheetLoader
-
- All Implemented Interfaces:
Serializable
,weka.core.converters.BatchConverter
,weka.core.converters.FileSourcedConverter
,weka.core.converters.Loader
,weka.core.EnvironmentHandler
,weka.core.OptionHandler
,weka.core.RevisionHandler
public class SpreadSheetLoader extends weka.core.converters.AbstractFileLoader implements weka.core.converters.BatchConverter, weka.core.OptionHandler
Loads a CSV file using an ADAMS spreadsheet reader and converts it into an Instances object.
Valid options are:
-D Enables debug output. (default: off)
-reader <classname + options> The ADAMS spreadsheet reader to use. (default: adams.data.io.input.CsvSpreadSheetReader)
-conversion <classname + options> The conversion scheme for converting the spreadsheet into an Instances object to work on. (default: adams.data.conversion.SpreadSheetToWekaInstances)
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
Loader
, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected adams.data.conversion.Conversion
m_Conversion
the conversion to use.protected weka.core.Instances
m_Data
the actual data.protected boolean
m_Debug
whether to print some debug informationprotected adams.data.io.input.SpreadSheetReader
m_Reader
the reader to use.protected File
m_sourceFile
Holds the source of the data set.protected weka.core.Instances
m_structure
Holds the determined structure (header) of the data set.
-
Constructor Summary
Constructors Constructor Description SpreadSheetLoader()
default constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
conversionTipText()
The tip text for this property.String
debugTipText()
the tip text for this propertyadams.data.conversion.Conversion
getConversion()
Returns the conversion in use for converting the spreadsheet into an Instances object.weka.core.Instances
getDataSet()
Return the full data set.boolean
getDebug()
Gets whether additional debug information is printed.String
getFileDescription()
Returns a description of the file type.String
getFileExtension()
Get the file extension used for this type of fileString[]
getFileExtensions()
Gets all the file extensions used for this type of fileweka.core.Instance
getNextInstance(weka.core.Instances structure)
SpreadSheetLoader is unable to process a data set incrementally.String[]
getOptions()
Gets the settingadams.data.io.input.SpreadSheetReader
getReader()
Returns the spreadsheet reader in use.String
getRevision()
Returns the revision string.weka.core.Instances
getStructure()
Determines and returns (if possible) the structure (internally the header) of the data set as an empty set of instances.String
globalInfo()
Returns a string describing this loaderEnumeration
listOptions()
Lists the available optionsstatic void
main(String[] args)
Main method.String
readerTipText()
The tip text for this property.void
reset()
Resets the loader ready to read a new data setvoid
setConversion(adams.data.conversion.Conversion value)
Sets the conversion to use for converting the spreadsheet into an Instances object.void
setDebug(boolean value)
Sets whether to print some debug information.void
setOptions(String[] options)
Parses a given list of options.void
setReader(adams.data.io.input.SpreadSheetReader value)
Sets the spreadsheet reader to use.void
setSource(File file)
Resets the Loader object and sets the source of the data set to be the supplied File object.-
Methods inherited from class weka.core.converters.AbstractFileLoader
getUseRelativePath, makeOptionStr, retrieveFile, runFileLoader, setEnvironment, setFile, setUseRelativePath, useRelativePathTipText
-
-
-
-
Field Detail
-
m_structure
protected weka.core.Instances m_structure
Holds the determined structure (header) of the data set.
-
m_Data
protected weka.core.Instances m_Data
the actual data.
-
m_sourceFile
protected File m_sourceFile
Holds the source of the data set.
-
m_Debug
protected boolean m_Debug
whether to print some debug information
-
m_Reader
protected adams.data.io.input.SpreadSheetReader m_Reader
the reader to use.
-
m_Conversion
protected adams.data.conversion.Conversion m_Conversion
the conversion to use.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing this loader- Returns:
- a description of the evaluator suitable for displaying in the explorer/experimenter gui
-
listOptions
public Enumeration listOptions()
Lists the available options- Specified by:
listOptions
in interfaceweka.core.OptionHandler
- Returns:
- an enumeration of the available options
-
setOptions
public void setOptions(String[] options) throws Exception
Parses a given list of options.
Valid options are:
-D Enables debug output. (default: off)
-reader <classname + options> The ADAMS spreadsheet reader to use. (default: adams.data.io.input.CsvSpreadSheetReader)
-conversion <classname + options> The conversion scheme for converting the spreadsheet into an Instances object to work on. (default: adams.data.conversion.SpreadSheetToWekaInstances)
- Specified by:
setOptions
in interfaceweka.core.OptionHandler
- Parameters:
options
- the options- Throws:
Exception
- if options cannot be set
-
getOptions
public String[] getOptions()
Gets the setting- Specified by:
getOptions
in interfaceweka.core.OptionHandler
- Returns:
- the current setting
-
setDebug
public void setDebug(boolean value)
Sets whether to print some debug information.- Parameters:
value
- if true additional debug information will be printed.
-
getDebug
public boolean getDebug()
Gets whether additional debug information is printed.- Returns:
- true if additional debug information is printed
-
debugTipText
public String debugTipText()
the tip text for this property- Returns:
- the tip text
-
setReader
public void setReader(adams.data.io.input.SpreadSheetReader value)
Sets the spreadsheet reader to use.- Parameters:
value
- the reader to use
-
getReader
public adams.data.io.input.SpreadSheetReader getReader()
Returns the spreadsheet reader in use.- Returns:
- the reader in use.
-
readerTipText
public String readerTipText()
The tip text for this property.- Returns:
- the tip text
-
setConversion
public void setConversion(adams.data.conversion.Conversion value)
Sets the conversion to use for converting the spreadsheet into an Instances object.- Parameters:
value
- the conversion
-
getConversion
public adams.data.conversion.Conversion getConversion()
Returns the conversion in use for converting the spreadsheet into an Instances object.- Returns:
- the conversion
-
conversionTipText
public String conversionTipText()
The tip text for this property.- Returns:
- the tip text
-
getFileDescription
public String getFileDescription()
Returns a description of the file type.- Specified by:
getFileDescription
in interfaceweka.core.converters.FileSourcedConverter
- Returns:
- a short file description
-
getFileExtension
public String getFileExtension()
Get the file extension used for this type of file- Specified by:
getFileExtension
in interfaceweka.core.converters.FileSourcedConverter
- Returns:
- the file extension
-
getFileExtensions
public String[] getFileExtensions()
Gets all the file extensions used for this type of file- Specified by:
getFileExtensions
in interfaceweka.core.converters.FileSourcedConverter
- Returns:
- the file extensions
-
reset
public void reset() throws IOException
Resets the loader ready to read a new data set- Specified by:
reset
in interfaceweka.core.converters.Loader
- Overrides:
reset
in classweka.core.converters.AbstractFileLoader
- Throws:
IOException
-
setSource
public void setSource(File file) throws IOException
Resets the Loader object and sets the source of the data set to be the supplied File object.- Specified by:
setSource
in interfaceweka.core.converters.Loader
- Overrides:
setSource
in classweka.core.converters.AbstractFileLoader
- Parameters:
file
- the source file.- Throws:
IOException
- if an error occurs
-
getStructure
public weka.core.Instances getStructure() throws IOException
Determines and returns (if possible) the structure (internally the header) of the data set as an empty set of instances.- Specified by:
getStructure
in interfaceweka.core.converters.Loader
- Specified by:
getStructure
in classweka.core.converters.AbstractLoader
- Returns:
- the structure of the data set as an empty set of Instances
- Throws:
IOException
- if an error occurs
-
getDataSet
public weka.core.Instances getDataSet() throws IOException
Return the full data set. If the structure hasn't yet been determined by a call to getStructure then method should do so before processing the rest of the data set.- Specified by:
getDataSet
in interfaceweka.core.converters.Loader
- Specified by:
getDataSet
in classweka.core.converters.AbstractLoader
- Returns:
- the structure of the data set as an empty set of Instances
- Throws:
IOException
- if there is no source or parsing fails
-
getNextInstance
public weka.core.Instance getNextInstance(weka.core.Instances structure) throws IOException
SpreadSheetLoader is unable to process a data set incrementally.- Specified by:
getNextInstance
in interfaceweka.core.converters.Loader
- Specified by:
getNextInstance
in classweka.core.converters.AbstractLoader
- Parameters:
structure
- ignored- Returns:
- never returns without throwing an exception
- Throws:
IOException
- always. AdamsCsvLoader is unable to process a data set incrementally.
-
getRevision
public String getRevision()
Returns the revision string.- Specified by:
getRevision
in interfaceweka.core.RevisionHandler
- Returns:
- the revision
-
main
public static void main(String[] args)
Main method.- Parameters:
args
- should contain the name of an input file.
-
-