def csvread(infile):
 out_csv = []
 errors = []
 index = (-1)
 p = LineParser(csv=True)
 for line in infile:
  index += 1
  try:
   values = p.feed(line)
  except ListQuoteError as e:
   values = []
   e.line = line
   e.index = index
   errors.append(e)
  out_csv.append(values)
 if errors:
  e = CSVError("Parsing CSV failed. See 'errors' attribute.")
  e.csv = out_csv
  e.errors = errors
  raise e
 return out_csv

def csvread ( infile ) : out_csv = [ ] errors = [ ] index = ( - 1 ) p = LineParser ( csv = True ) for line in infile : index += 1 try : values = p . feed ( line ) except ListQuoteError as e : values = [ ] e . line = line e . index = index errors . append ( e ) out_csv . append ( values ) if errors : e = CSVError ( "Parsing CSV failed. See 'errors' attribute." ) e . csv = out_csv e . errors = errors raise e return out_csv
given an infile as an iterable .