@@ -0,0 +1,2237 @@
+import csv%0Afrom django.template.defaultfilters import slugify%0A%0Afrom core.models import Bowstyle, Club, Archer%0Afrom entries.models import CompetitionEntry, SessionEntry, SessionRound, Competition, TargetAllocation%0A%0Acompetition = Competition.objects.get(slug='bucs-indoors-2012')%0Asession_rounds = SessionRound.objects.filter(session__competition=competition)%0A%0Aclubs = set()%0Atotal = 0%0Afor session_name, session_round in zip(%5B'A', 'B', 'C'%5D, session_rounds):%0A    file_name = '/home/marc/Desktop/BUSA%25s.csv' %25 session_name%0A    f = open(file_name, 'r')%0A    reader = csv.reader(f)%0A    rows = filter(lambda r: r%5B1%5D, reader)%0A    rows = %5Brow%5B:5%5D for row in rows%5D%0A    for target, archer, bow, club, exp in rows:%0A        bowstyle = Bowstyle.objects.get(name__iexact=bow)%0A        #if exp%5B0%5D not in %5B'E', 'N'%5D:%0A        #    print exp%0A        exp = exp%5B0%5D%0A        club = Club.objects.get(short_name__iexact=club.strip() + ' Uni')%0A        # get or create archer%0A        try:%0A            archer = Archer.objects.get(name__iexact=archer, club=club)%0A        except Archer.DoesNotExist:%0A            archer = Archer(name=archer, club=club, novice=exp, age='S', bowstyle=bowstyle, gender='G')%0A            archer.save()%0A        # get or create competition entry%0A        competition_entry, created = CompetitionEntry.objects.get_or_create(competition=competition, archer=archer, bowstyle=bowstyle, novice=exp, age='S', club=club)%0A        session_entry, created = SessionEntry.objects.get_or_create(competition_entry=competition_entry, session_round=session_round)%0A        target_allocation, created = TargetAllocation.objects.get_or_create(session_entry=session_entry, boss=target%5B:-1%5D, target=target%5B-1%5D)%0A        print target%5B:-1%5D, target%5B-1%5D, archer%0A%0A%0A#clubs = sorted(list(clubs))%0A#for club in clubs:%0A#    club = club + ' Uni'%0A#    try:%0A#        club = Club.objects.get(short_name__iexact=club)%0A#        print club.pk, club.name%0A#        continue%0A#    except Club.DoesNotExist:%0A#        full_name = club + 'versity Archery Club'%0A#        abbreviation = ''.join(%5Bn%5B0%5D for n in full_name.split(' ')%5D)%0A#        club = Club(name=full_name, short_name=club, abbreviation=abbreviation)%0A#        club.clean()%0A#        club.save()%0A#        print club.pk, club.name%0A#%0A

Add a csv import script (specific to BUCS)