-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathclass_info.py
32 lines (27 loc) · 879 Bytes
/
class_info.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
# importing the csv module
import csv
# field names
fields = ['Section ID', 'Teacher']
# data rows of csv file
# rows = [ ['Nikhil', 'COE', '2', '9.0'],
# ['Sanchit', 'COE', '2', '9.1'],
# ['Aditya', 'IT', '2', '9.3'],
# ['Sagar', 'SE', '1', '9.5'],
# ['Prateek', 'MCE', '3', '7.8'],
# ['Sahil', 'EP', '2', '9.1']]
blank_row = []
rows = ['Student', 'Student'] #Should contain additional lists within
filename = "Information.csv" #File can also be .xlsx
students = [['Pranav'], ['Jimmy'], ['Leo'], ['Henry']]
# writing to csv file
with open(filename, 'w') as csvfile:
# creating a csv writer object
csvwriter = csv.writer(csvfile)
#USE WRITEROWS WHEN PARSING ARRAYS
# writing the fields
csvwriter.writerow(fields)
csvwriter.writerow(blank_row)
# writing the data rows
csvwriter.writerow(rows)
csvwriter.writerows(students)
csvfile.close()