-
Notifications
You must be signed in to change notification settings - Fork 0
/
csvreaderformoodle.py
33 lines (29 loc) · 1.04 KB
/
csvreaderformoodle.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
import csv, re
jhubvalues = {}
jhubvaluemapping = {
'Course': 'SHORTCOURSE',
'Branch': 'BRANCH_REQUESTED',
'Github': 'REQUESTED_GITHUB_REPO_LINK',
'CPU': 'REQUESTED_CPU',
'Memory': 'REQUESTED_MEMORY',
'Container': 'REQUESTED_CONTAINER',
'Software': 'REQUIRED_SOFTWARE',
'Containerfile': 'DOCKERFILE',
'Dockerhub': 'DOCKERHUB',
'Permission': 'PERMISSION_TO_SHARE'
}
with open('surveyresponse.csv', mode='r') as infile: #or whatever the .csv file is called
reader = csv.DictReader(infile)
responses = next(reader) #will only read one line, first line only
#loop using keys
for keys in responses:
strippedkey = (re.sub('[()]','', keys.split(' ', 1)[0]))
#This if statement was required when Github appeared in too separate question labels
#if "(" not in keys:
# continue
#strippedkey = keys.split("(")[1].split(")")[0]
print(strippedkey)
if strippedkey in jhubvaluemapping: #ie should not be an empty answer
moodlevalue = jhubvaluemapping[strippedkey]
jhubvalues[moodlevalue] = responses[keys]
print (jhubvalues)