def fixed2csv(f, schema, output=None, **kwargs):
 streaming = (True if output else False)
 if (not streaming):
  output = six.StringIO()
 try:
  encoding = kwargs['encoding']
 except KeyError:
  encoding = None
 writer = agate.csv.writer(output)
 reader = FixedWidthReader(f, schema, encoding=encoding)
 writer.writerows(reader)
 if (not streaming):
  data = output.getvalue()
  output.close()
  return data
 return ''

def fixed2csv ( f , schema , output = None , ** kwargs ) : streaming = ( True if output else False ) if ( not streaming ) : output = six . StringIO ( ) try : encoding = kwargs [ 'encoding' ] except KeyError : encoding = None writer = agate . csv . writer ( output ) reader = FixedWidthReader ( f , schema , encoding = encoding ) writer . writerows ( reader ) if ( not streaming ) : data = output . getvalue ( ) output . close ( ) return data return ''
convert a fixed-width file to csv using a csv-formatted schema description .