Posted By

kerpunk on 02/23/10


Tagged

textmate python csv django


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

gartenstuhl


Django CSV


 / Published in: Other
 

  1. reader = csv.reader(open("/Users/development/Desktop/experiences.csv"))
  2. for row in reader:
  3. e = Event.objects.filter(name__iexact=row[1])
  4. if e.count < 1:
  5. pass
  6.  
  7. reader = csv.reader(open("/Users/development/Desktop/experiences.csv"))
  8. for row in reader:
  9. v = Venue.objects.filter(name__iexact=row[1])
  10. if v.count() < 1:
  11. venue = Venue(name=row[1], address=row[2], postcode=row[4])
  12. venue.save()
  13. else:
  14. venue = Venue.objects.get(name__iexact=row[1])
  15. ex = Experience(name=row[0], category=slugify(row[5]), description=row[7], venue=venue)
  16. ex.save()
  17.  

Report this snippet  

You need to login to post a comment.