def __init__(self): """Create an empty Batch object.""" self.nbytes = 0 # bytes in batch so far self.nlines = 0 # lines in batch so far self.data = pyStringIO() Batch.total_batches += 1 # sequentially number these self.batchno = Batch.total_batches self.csv_writer = csv.writer(self.data) if _args.delim else None
def string_io(data=None): # cStringIO can't handle unicode ''' Pass data through to stringIO module and return result ''' try: return cStringIO(bytes(data)) except UnicodeEncodeError: return pyStringIO(data)
def string_io(data=None): # cStringIO can't handle unicode try: return cStringIO(bytes(data)) except UnicodeEncodeError: return pyStringIO(data)
def StringIO(s=None): # cStringIO can't handle unicode try: return cStringIO(bytes(s)) except UnicodeEncodeError: return pyStringIO(s)