weka.core.converters
Class ExcelLoader

java.lang.Object
  extended by weka.core.converters.AbstractLoader
      extended by weka.core.converters.AbstractFileLoader
          extended by weka.core.converters.ExcelLoader
All Implemented Interfaces:
Serializable, weka.core.converters.BatchConverter, weka.core.converters.FileSourcedConverter, weka.core.converters.Loader, weka.core.converters.URLSourcedLoader, weka.core.EnvironmentHandler, weka.core.OptionHandler, weka.core.RevisionHandler

public class ExcelLoader
extends weka.core.converters.AbstractFileLoader
implements weka.core.converters.BatchConverter, weka.core.converters.URLSourcedLoader, weka.core.OptionHandler

Reads a source that is in the Excel spreadsheet format.
For instance, a spreadsheet generated with the Microsoft Office Suite.

Valid options are:

 -sheet <index>
  The index of the sheet to load; 'first' and 'last' are accepted as well.
 -M <str>
  The string representing a missing value.
  (default: '')
For a tutorial on ExcelDOM, see:
http://java.dzone.com/news/integrate-openoffice-java

Version:
$Revision: 8109 $
Author:
FracPete (fracpete at waikato dot ac dot nz), Geertjan Wielenga
See Also:
Loader, Serialized Form

Field Summary
static String FILE_DESCRIPTION
          the file description.
static String FILE_EXTENSION
          the binary file extension.
static String FILE_EXTENSION_OOXML
          the OOXML file extension.
 
Fields inherited from class weka.core.converters.AbstractFileLoader
FILE_EXTENSION_COMPRESSED
 
Fields inherited from interface weka.core.converters.Loader
BATCH, INCREMENTAL, NONE
 
Constructor Summary
ExcelLoader()
           
 
Method Summary
 weka.core.Instances getDataSet()
          Return the full data set.
 String getFileDescription()
          Returns a description of the file type.
 String getFileExtension()
          Get the file extension used for JSON files.
 String[] getFileExtensions()
          Gets all the file extensions used for this type of file.
 String getMissingValue()
          Returns the current placeholder for missing values.
 weka.core.Instance getNextInstance(weka.core.Instances structure)
          JSONLoader is unable to process a data set incrementally.
 String[] getOptions()
          returns the options of the current setup.
 String getRevision()
          Returns the revision string.
 String getSheetIndex()
          Returns the index of the sheet to load.
 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 Loader.
 Enumeration listOptions()
          Returns an enumeration describing the available options.
static void main(String[] args)
          Main method.
 String missingValueTipText()
          Returns the tip text for this property.
 void reset()
          Resets the Loader ready to read a new data set.
 String retrieveURL()
          Return the current url.
 void setMissingValue(String value)
          Sets the placeholder for missing values.
 void setOptions(String[] options)
          Parses the options for this object.
 void setSheetIndex(String value)
          Sets the index of the sheet to load.
 void setSource(InputStream in)
          Resets the Loader object and sets the source of the data set to be the supplied InputStream.
 void setSource(URL url)
          Resets the Loader object and sets the source of the data set to be the supplied url.
 void setURL(String url)
          Set the url to load from.
 String sheetIndexTipText()
          Returns the tip text for this property.
 
Methods inherited from class weka.core.converters.AbstractFileLoader
getUseRelativePath, retrieveFile, runFileLoader, setEnvironment, setFile, setSource, setUseRelativePath, useRelativePathTipText
 
Methods inherited from class weka.core.converters.AbstractLoader
setRetrieval
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILE_EXTENSION

public static String FILE_EXTENSION
the binary file extension.


FILE_EXTENSION_OOXML

public static String FILE_EXTENSION_OOXML
the OOXML file extension.


FILE_DESCRIPTION

public static String FILE_DESCRIPTION
the file description.

Constructor Detail

ExcelLoader

public ExcelLoader()
Method Detail

globalInfo

public String globalInfo()
Returns a string describing this Loader.

Returns:
a description of the Loader suitable for displaying in the explorer/experimenter gui

listOptions

public Enumeration listOptions()
Returns an enumeration describing the available options.

Specified by:
listOptions in interface weka.core.OptionHandler
Returns:
an enumeration of all the available options.

getOptions

public String[] getOptions()
returns the options of the current setup.

Specified by:
getOptions in interface weka.core.OptionHandler
Returns:
the current options

setOptions

public void setOptions(String[] options)
                throws Exception
Parses the options for this object.

Valid options are:

 -sheet <index>
  The index of the sheet to load; 'first' and 'last' are accepted as well.
 -M <str>
  The string representing a missing value.
  (default: '')

Specified by:
setOptions in interface weka.core.OptionHandler
Parameters:
options - the options to use
Throws:
Exception - if setting of options fails

setMissingValue

public void setMissingValue(String value)
Sets the placeholder for missing values.

Parameters:
value - the placeholder

getMissingValue

public String getMissingValue()
Returns the current placeholder for missing values.

Returns:
the placeholder

missingValueTipText

public String missingValueTipText()
Returns the tip text for this property.

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

getFileExtension

public String getFileExtension()
Get the file extension used for JSON files.

Specified by:
getFileExtension in interface weka.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 interface weka.core.converters.FileSourcedConverter
Returns:
the file extensions

getFileDescription

public String getFileDescription()
Returns a description of the file type.

Specified by:
getFileDescription in interface weka.core.converters.FileSourcedConverter
Returns:
a short file description

reset

public void reset()
           throws IOException
Resets the Loader ready to read a new data set.

Specified by:
reset in interface weka.core.converters.Loader
Overrides:
reset in class weka.core.converters.AbstractFileLoader
Throws:
IOException - if something goes wrong

setSheetIndex

public void setSheetIndex(String value)
Sets the index of the sheet to load.

Parameters:
value - the index (1-based, 'first' and 'last' accepted as well)

getSheetIndex

public String getSheetIndex()
Returns the index of the sheet to load.

Returns:
the index (1-based, 'first' and 'last' accepted as well)

sheetIndexTipText

public String sheetIndexTipText()
Returns the tip text for this property.

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

setSource

public void setSource(URL url)
               throws IOException
Resets the Loader object and sets the source of the data set to be the supplied url.

Parameters:
url - the source url.
Throws:
IOException - if an error occurs

setURL

public void setURL(String url)
            throws IOException
Set the url to load from.

Specified by:
setURL in interface weka.core.converters.URLSourcedLoader
Parameters:
url - the url to load from
Throws:
IOException - if the url can't be set.

retrieveURL

public String retrieveURL()
Return the current url.

Specified by:
retrieveURL in interface weka.core.converters.URLSourcedLoader
Returns:
the current url

setSource

public void setSource(InputStream in)
               throws IOException
Resets the Loader object and sets the source of the data set to be the supplied InputStream.

Specified by:
setSource in interface weka.core.converters.Loader
Overrides:
setSource in class weka.core.converters.AbstractLoader
Parameters:
in - the source InputStream.
Throws:
IOException - if initialization of reader fails.

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 interface weka.core.converters.Loader
Specified by:
getStructure in class weka.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 interface weka.core.converters.Loader
Specified by:
getDataSet in class weka.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
JSONLoader is unable to process a data set incrementally.

Specified by:
getNextInstance in interface weka.core.converters.Loader
Specified by:
getNextInstance in class weka.core.converters.AbstractLoader
Parameters:
structure - ignored
Returns:
never returns without throwing an exception
Throws:
IOException - always. JSONLoader is unable to process a data set incrementally.

getRevision

public String getRevision()
Returns the revision string.

Specified by:
getRevision in interface weka.core.RevisionHandler
Returns:
the revision

main

public static void main(String[] args)
Main method.

Parameters:
args - should contain the name of an input file.


Copyright © 2012 University of Waikato, Hamilton, NZ. All Rights Reserved.