-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd-abbrvs.py
35 lines (30 loc) · 1.06 KB
/
add-abbrvs.py
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
27
28
29
30
31
32
33
34
35
from summit.apps.projects.models import Project
from summit.apps.projects.models import Location
from summit.libs.auth.models import CESU
from summit.libs.auth.models import Organization
from summit.libs.auth.models import UserProfile
import csv
from datetime import datetime
from decimal import Decimal
from django.core.exceptions import ObjectDoesNotExist
# read line
with open('agency_acronyms.csv',encoding='utf-8-sig', newline='') as csvfile:
reader = csv.DictReader(csvfile, quotechar='"')
for row in reader:
if (row['Federal Agency'] != ""):
org = Organization.objects.get_or_create(
name = row['Federal Agency'],
)[0]
org.abbrv = row['Acronym']
org.save()
print(org.abbrv)
with open('partner_acronyms.csv',encoding='utf-8-sig', newline='') as csvfile:
reader = csv.DictReader(csvfile, quotechar='"')
for row in reader:
if (row['Partner'] != ""):
org = Organization.objects.get_or_create(
name = row['Partner'],
)[0]
org.abbrv = row['Acronym']
org.save()
print(org.abbrv)