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.OptionHandlerLoads 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 Conversionm_Conversionthe conversion to use.protected weka.core.Instancesm_Datathe actual data.protected booleanm_Debugwhether to print some debug informationprotected SpreadSheetReaderm_Readerthe reader to use.protected Filem_sourceFileHolds the source of the data set.protected weka.core.Instancesm_structureHolds 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 StringconversionTipText()The tip text for this property.StringdebugTipText()the tip text for this propertyConversiongetConversion()Returns the conversion in use for converting the spreadsheet into an Instances object.weka.core.InstancesgetDataSet()Return the full data set.booleangetDebug()Gets whether additional debug information is printed.StringgetFileDescription()Returns a description of the file type.StringgetFileExtension()Get the file extension used for this type of fileString[]getFileExtensions()Gets all the file extensions used for this type of fileweka.core.InstancegetNextInstance(weka.core.Instances structure)SpreadSheetLoader is unable to process a data set incrementally.String[]getOptions()Gets the settingSpreadSheetReadergetReader()Returns the spreadsheet reader in use.StringgetRevision()Returns the revision string.weka.core.InstancesgetStructure()Determines and returns (if possible) the structure (internally the header) of the data set as an empty set of instances.StringglobalInfo()Returns a string describing this loaderEnumerationlistOptions()Lists the available optionsstatic voidmain(String[] args)Main method.StringreaderTipText()The tip text for this property.voidreset()Resets the loader ready to read a new data setvoidsetConversion(Conversion value)Sets the conversion to use for converting the spreadsheet into an Instances object.voidsetDebug(boolean value)Sets whether to print some debug information.voidsetOptions(String[] options)Parses a given list of options.voidsetReader(SpreadSheetReader value)Sets the spreadsheet reader to use.voidsetSource(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 SpreadSheetReader m_Reader
the reader to use.
-
m_Conversion
protected 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:
listOptionsin 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:
setOptionsin interfaceweka.core.OptionHandler- Parameters:
options- the options- Throws:
Exception- if options cannot be set
-
getOptions
public String[] getOptions()
Gets the setting- Specified by:
getOptionsin 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(SpreadSheetReader value)
Sets the spreadsheet reader to use.- Parameters:
value- the reader to use
-
getReader
public 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(Conversion value)
Sets the conversion to use for converting the spreadsheet into an Instances object.- Parameters:
value- the conversion
-
getConversion
public 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:
getFileDescriptionin 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:
getFileExtensionin 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:
getFileExtensionsin interfaceweka.core.converters.FileSourcedConverter- Returns:
- the file extensions
-
reset
public void reset() throws IOExceptionResets the loader ready to read a new data set- Specified by:
resetin interfaceweka.core.converters.Loader- Overrides:
resetin 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:
setSourcein interfaceweka.core.converters.Loader- Overrides:
setSourcein classweka.core.converters.AbstractFileLoader- Parameters:
file- the source file.- Throws:
IOException- if an error occurs
-
getStructure
public weka.core.Instances getStructure() throws IOExceptionDetermines and returns (if possible) the structure (internally the header) of the data set as an empty set of instances.- Specified by:
getStructurein interfaceweka.core.converters.Loader- Specified by:
getStructurein 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 IOExceptionReturn 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:
getDataSetin interfaceweka.core.converters.Loader- Specified by:
getDataSetin 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 IOExceptionSpreadSheetLoader is unable to process a data set incrementally.- Specified by:
getNextInstancein interfaceweka.core.converters.Loader- Specified by:
getNextInstancein 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:
getRevisionin 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.
-
-