Exemplo n.º 1
0
 def make_data_output(self) :
     fs = self.config.get_io(datagentoken.outkw)
     ov = self.get_vars_by_category(
         datagentoken.rwkw,
         datagentoken.genkw
     )
     rv = csvfileio.CsvFileIo(fs, True, ov)
     return rv
Exemplo n.º 2
0
def read(name, factory, cols=None):
    f = name + '.csv'
    with csvfileio.CsvFileIo(f, False) as rdr:
        if cols is None:
            cols = rdr.fieldnames
        temp = factory.new_table(name, cols)
        temp.add_rows(rdr)
    return temp
Exemplo n.º 3
0
 def write(self, *files):
     headers = self.start_write()
     for f in files:
         self.current_output = f
         with csvfileio.CsvFileIo(f, True, headers) as rtr:
             rtr.writeheader()
             for row in self.get_next_output_row():
                 rtr.writerow(row)
         self.current_output = None
     self.finish_write()
Exemplo n.º 4
0
 def read(self, *files):
     self.start_read()
     for f in files:
         self.current_input = f
         with csvfileio.CsvFileIo(f, False) as rdr:
             if not self.pre_row_processing(rdr.fieldnames):
                 continue
             for row in rdr:
                 self.process_row(row)
             self.post_row_processing()
         self.current_input = None
     self.finish_read()
Exemplo n.º 5
0
def write(table, cols=None):
    f = table.get_name() + '.csv'
    if cols is None:
        cols = table.get_cols()
    with csvfileio.CsvFileIo(f, True, cols) as rtr:
        rtr.writeheader()
        for row in table:
            if type(row) == type([]):
                d = dict(zip(cols, row))
            else:
                d = row.as_dict()
            rtr.writerow(d)
Exemplo n.º 6
0
 def make_data_input(self) :
     fn = self.config.get_io(datagentoken.inpkw)
     rv = csvfileio.CsvFileIo(fn, False) 
     return rv