Package PyML :: Package containers :: Module parsers :: Class CSVParser
[frames] | no frames]

Class CSVParser

source code

base.pymlObject.PyMLobject --+    
                             |    
                        Parser --+
                                 |
                                CSVParser

A class for parsing delimited files
Instance Methods
 
__init__(self, file, **args) source code
 
check(self)
very loose checking of the format of the file: if the first line does not contain a colon (":") it is assumed to be in csv format the delimiter is determined to be "," if the first line contains at least one comma; otherwise a split on whitespaces is used.
source code
 
skipHeader(self, line, pos)
check if the file has a first line that provides the feature IDs
source code
 
readLabels(self) source code
 
scan(self) source code
 
next(self) source code
 
postProcess(self) source code
    Inherited from Parser
 
__iter__(self) source code
 
__len__(self)
how many patterns are read
source code
 
skipComments(self) source code
Class Variables
  attributes = {'idColumn': None, 'labelsColumn': None, 'headerR...
    Inherited from Parser
  commentChar = ['%', '#']
Method Details

__init__(self, file, **args)
(Constructor)

source code 
Parameters:
  • headerRow - True/False depending on whether the file contains a header row that provides feature IDs
  • idColumn - set to 0 if the data has pattern IDs in the first column
  • labelsColumn - possible values: if there are no patternIDs it is either 0 or -1, and if there are patternIDs, 1 or -1
Overrides: Parser.__init__

check(self)

source code 
very loose checking of the format of the file: if the first line does not contain a colon (":") it is assumed to be in csv format the delimiter is determined to be "," if the first line contains at least one comma; otherwise a split on whitespaces is used.
Overrides: Parser.check

scan(self)

source code 
Overrides: Parser.scan

next(self)

source code 
Overrides: Parser.next

Class Variable Details

attributes

Value:
{'idColumn': None, 'labelsColumn': None, 'headerRow': False}