blob: 339811c9506f44f5e3a47188cb2d82076b665216 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
import os
import datetime
from datetime import timedelta
Date = datetime.datetime.now()
def populate():
#file_obj=open("data_of_rc.csv")
#print file_obj
#file_obj.close()
f=open("category_names.txt")
for line in f:
cname=line.replace("\n","")
cat_added=add_category(cname)
f.close()
def add_category(cname):
cat = FossCategory.objects.get_or_create(name=cname,description=cname,date_created=Date,date_modified=Date)[0]#for now description is same as category_names
print "category " +str(cname)+" added at "+str(Date)
return cat
# Start execution here!
if __name__ == '__main__':
print "Starting population script for adding category..."
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'forums.settings')
from website.models import *
populate()
|