summaryrefslogtreecommitdiff
path: root/aloha/allotter/management/commands/dumpcsv.py
blob: e1c87787182f03bde2abf69b4790a3a6352779f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from csv import writer
from django.core.management.base import BaseCommand
from allotter.models import Application

class Command(BaseCommand):
    help = "Give the filename of the csv files that has all the details of the users"
    
    def handle(self, *args, **options):
        
        dump_csv()
        
        self.stdout.write('Done\n')
        
def dump_csv():
    application = Application.objects.all()    
    csvWriter = writer(open('csvdump.csv', 'w'), delimiter=":")
    csvWriter.writerow(['RegNo.','np','cat', 'option_selected'])
    for users in application:
        csvWriter.writerow([users.user, users.np,users.cgy, users.options_selected])