Documentation of 'smile.data.parser.DelimitedTextParser' Java class
DelimitedTextParser
smile.data.parser

Class DelimitedTextParser



  • public class DelimitedTextParser
    extends java.lang.Object
    The delimited text file parser. By default, the parser expects a white-space-separated-values file. Each line in the file corresponds to a row in the table. Within a line, fields are separated by white spaces, each field belonging to one table column. This class can also be used to read other text tabular files by setting delimiter character such ash ','. The file may contain comment lines (starting with '%') and missing values (indicated by placeholder '?'), which both can be parameterized.
    • Constructor Detail

      • DelimitedTextParser

        public DelimitedTextParser()
        Constructor with default delimiter of white space, comment line starting with '%', missing value placeholder "?", no column names, no row names.
    • Method Detail

      • getDelimiter

        public java.lang.String getDelimiter()
        Returns the delimiter character/string.
      • setDelimiter

        public DelimitedTextParser setDelimiter(java.lang.String delimiter)
        Set the delimiter character/string.
      • getCommentStartWith

        public java.lang.String getCommentStartWith()
        Returns the character/string that starts a comment line.
      • setCommentStartWith

        public DelimitedTextParser setCommentStartWith(java.lang.String comment)
        Set the character/string that starts a comment line.
      • getMissingValuePlaceholder

        public java.lang.String getMissingValuePlaceholder()
        Returns the missing value placeholder.
      • setMissingValuePlaceholder

        public DelimitedTextParser setMissingValuePlaceholder(java.lang.String missing)
        Set the missing value placeholder.
      • setResponseIndex

        public DelimitedTextParser setResponseIndex(Attribute response,
                                                    int index)
        Sets the attribute and column index (starting at 0) of dependent/response variable.
      • setIgnoredColumns

        public DelimitedTextParser setIgnoredColumns(java.util.List<java.lang.Integer> ignoredColumns)
        Sets the list of column indices to ignore (starting at 0)
      • addIgnoredColumn

        public DelimitedTextParser addIgnoredColumn(int index)
        Adds one columns index to ignore
      • addIgnoredColumns

        public DelimitedTextParser addIgnoredColumns(java.util.List<java.lang.Integer> ignoredColumns)
        Adds several column indices to ignore
      • hasRowNames

        public boolean hasRowNames()
        Returns if the dataset has row names (at column 0).
      • setRowNames

        public DelimitedTextParser setRowNames(boolean hasRowNames)
        Set if the dataset has row names (at column 0).
      • hasColumnNames

        public boolean hasColumnNames()
        Returns if the dataset has column namesS (at row 0).
      • setColumnNames

        public DelimitedTextParser setColumnNames(boolean hasColNames)
        Set if the dataset has column names (at row 0).
      • parse

        public AttributeDataset parse(java.net.URI uri)
                               throws java.io.IOException,
                                      java.text.ParseException
        Parse a dataset from given URI.
        Throws:
        java.io.FileNotFoundException
        java.io.IOException
        java.text.ParseException
      • parse

        public AttributeDataset parse(java.lang.String name,
                                      Attribute[] attributes,
                                      java.net.URI uri)
                               throws java.io.IOException,
                                      java.text.ParseException
        Parse a dataset from given URI.
        Parameters:
        uri - the URI of data source.
        attributes - the list attributes of data in proper order.
        Throws:
        java.io.FileNotFoundException
        java.io.IOException
        java.text.ParseException
      • parse

        public AttributeDataset parse(java.lang.String path)
                               throws java.io.IOException,
                                      java.text.ParseException
        Parse a dataset from given file.
        Parameters:
        path - the file path of data source.
        Throws:
        java.io.FileNotFoundException
        java.io.IOException
        java.text.ParseException
      • parse

        public AttributeDataset parse(Attribute[] attributes,
                                      java.lang.String path)
                               throws java.io.IOException,
                                      java.text.ParseException
        Parse a dataset from given file.
        Parameters:
        path - the file path of data source.
        attributes - the list attributes of data in proper order.
        Throws:
        java.io.FileNotFoundException
        java.io.IOException
        java.text.ParseException
      • parse

        public AttributeDataset parse(java.lang.String name,
                                      Attribute[] attributes,
                                      java.lang.String path)
                               throws java.io.IOException,
                                      java.text.ParseException
        Parse a dataset from given file.
        Parameters:
        path - the file path of data source.
        attributes - the list attributes of data in proper order.
        Throws:
        java.io.FileNotFoundException
        java.io.IOException
        java.text.ParseException
      • parse

        public AttributeDataset parse(java.io.File file)
                               throws java.io.IOException,
                                      java.text.ParseException
        Parse a dataset from given file.
        Parameters:
        file - the file of data source.
        Throws:
        java.io.FileNotFoundException
        java.io.IOException
        java.text.ParseException
      • parse

        public AttributeDataset parse(java.lang.String name,
                                      java.io.File file)
                               throws java.io.IOException,
                                      java.text.ParseException
        Parse a dataset from given file.
        Parameters:
        file - the file of data source.
        Throws:
        java.io.IOException
        java.text.ParseException
      • parse

        public AttributeDataset parse(Attribute[] attributes,
                                      java.io.File file)
                               throws java.io.IOException,
                                      java.text.ParseException
        Parse a dataset from given file.
        Parameters:
        file - the file of data source.
        attributes - the list attributes of data in proper order.
        Throws:
        java.io.IOException
        java.text.ParseException
      • parse

        public AttributeDataset parse(java.lang.String name,
                                      Attribute[] attributes,
                                      java.io.File file)
                               throws java.io.IOException,
                                      java.text.ParseException
        Parse a dataset from given file.
        Parameters:
        file - the file of data source.
        attributes - the list attributes of data in proper order.
        Throws:
        java.io.FileNotFoundException
        java.io.IOException
        java.text.ParseException
      • parse

        public AttributeDataset parse(java.lang.String name,
                                      java.io.InputStream stream)
                               throws java.io.IOException,
                                      java.text.ParseException
        Parse a dataset from an input stream.
        Parameters:
        name - the name of dataset.
        stream - the input stream of data.
        Throws:
        java.io.FileNotFoundException
        java.io.IOException
        java.text.ParseException

DataMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.