chaind-eth

Queue server for ethereum
Info | Log | Files | Refs | README | LICENSE

csv.py (586B)


      1 # standard imports
      2 import logging
      3 
      4 logg = logging.getLogger(__name__)
      5 
      6 
      7 class CSVProcessor:
      8 
      9     def load(self, s):
     10         contents = []
     11         f = None
     12         try:
     13             f = open(s, 'r')
     14         except FileNotFoundError:
     15             return None
     16 
     17         import csv # only import if needed
     18         fr = csv.reader(f)
     19 
     20         for r in fr:
     21             contents.append(r)
     22         f.close()
     23         l = len(contents)
     24         logg.info('successfully parsed source as csv, found {} records'.format(l))
     25         return contents
     26 
     27 
     28     def __str__(self):
     29         return 'csv processor'