csv cleanpop function


/ Published in: Python
Save to your folder(s)



Copy this code and paste it in your HTML
  1. def cleanpop(csvReader,parameters):
  2. for row in csvReader:
  3. fail=False
  4. match=True
  5. for test in parameters:
  6. ind = test[0]; val = test[1]
  7. #print "index %i and value %s"%(ind,val)
  8. if len(test) > 2:
  9. match = (test[2] != "in")
  10. if match and row[ind]==val:
  11. # print "match"
  12. fail=True
  13. elif val in row[ind]:
  14. # print "in"
  15. fail=True
  16. if fail:
  17. #print "failed row:"
  18. #print row
  19. continue
  20. yield row

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.