| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

DybDbi::csvrw::Source Class Reference

List of all members.

Public Member Functions

def __init__
def is_descline
def descline
def next
def __iter__
def __repr__

Public Attributes

 cols

Detailed Description

Behaves like a file and holds the original text of the CSV. 
Applies some fixes to make readable as CSV::

#. removes comments
#. normalize the description line to conform to the delimiter
 

Definition at line 132 of file csvrw.py.


Member Function Documentation

def DybDbi::csvrw::Source::__init__ (   self,
  f,
  delimiter = "\t",
  prefix = "#Table",
  descmarker = "#[]",
  synth = "srcline" 
)

:param delimiter: csv field divider
:param prefix:  string start of lines to be ignored
:param descmarker: strings used to identify the field description line 
:param synth: when defined, add extra field with this name to hold the csv source line number 

Definition at line 134 of file csvrw.py.

00141                                                                                              :
00142         """
00143         :param delimiter: csv field divider
00144         :param prefix:  string start of lines to be ignored
00145         :param descmarker: strings used to identify the field description line 
00146         :param synth: when defined, add extra field with this name to hold the csv source line number 
00147         """
00148         self.f = f
00149         self.prefix = prefix
        self.delimiter = delimiter

def DybDbi::csvrw::Source::is_descline (   self,
  line 
)

Checks if line contains all of the description markers

Definition at line 150 of file csvrw.py.

00157                                :
        """

def DybDbi::csvrw::Source::descline (   self,
  line 
)

Definition at line 156 of file csvrw.py.

00157                                :
00158         """
00159         Checks if line contains all of the description markers
00160         """
        return len(filter(lambda _:_ in line,self.descmarker)) == len(self.descmarker)

def DybDbi::csvrw::Source::next (   self  ) 

Definition at line 161 of file csvrw.py.

00161                                   :_ in line,self.descmarker)) == len(self.descmarker)
00162 
00163     def descline(self, line):
00164         for c in self.descmarker:
00165              line = line.replace(c,"")
00166         return line
00167 
00168     def next(self):
00169         line = self.f.next()
00170         self.append(line.rstrip())
00171         self.stat['total'] += 1
00172         while line.startswith(self.prefix):
00173             self.stat['prefix'] += 1
00174             line = self.f.next()
00175         else:
00176             if self.is_descline(line):
00177                 self.stat['descline'] += 1
00178                 if self.synth:

def DybDbi::csvrw::Source::__iter__ (   self  ) 

Definition at line 179 of file csvrw.py.

00181                 :
                self.stat['payload'] += 1

def DybDbi::csvrw::Source::__repr__ (   self  ) 

Definition at line 182 of file csvrw.py.

00183                              : 
00184                     line = "%d" % (len(self) - 1) + self.delimiter + line 
00185             return line


Member Data Documentation

DybDbi::csvrw::Source::cols

Definition at line 173 of file csvrw.py.


The documentation for this class was generated from the following file:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:17:17 2011 for DybDbi by doxygen 1.4.7