This repository has been archived by the owner on Mar 19, 2020. It is now read-only.
forked from nealrs/expo
-
Notifications
You must be signed in to change notification settings - Fork 2
/
new-table-assigner.py
60 lines (47 loc) · 1.63 KB
/
new-table-assigner.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import csv, random
table_list = [i for i in range(1,130)]
expo_list = ["1"]
#get submissions from csv
title_col = "Submission Title"
description_col = "Plain Description"
sponsors_row = "Desired Prizes"
link_col = "Submission Url"
input_path = 'data/data.csv'
output_full_path = 'data/data_full.csv'
output_gavel_path = 'data/data_gavel.csv'
gavel = []
full = []
with open(input_path, newline='') as csvfile:
submissions_reader = csv.DictReader(csvfile)
free_tables = table_list[:]
print(table_list)
for row in submissions_reader:
print(row[title_col])
table = random.choice(free_tables) #(0, len(free_tables)-1)
full.append(row)
gavel.append({'project': row[title_col], 'location': table, 'description':
row[description_col][:200]})
# complete_list[-1]["expo"] = expo_list[expo]
full[-1]['table'] = table
free_tables.remove(table)
# write full file (for expo website)
with open(output_full_path, 'w') as csvfile:
fieldnames = ['table', 'project', 'sponsors', 'link']
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
writer.writeheader()
for row in full:
writer.writerow(
{
'table': row['table'],
'project': row[title_col],
'sponsors': row[sponsors_row],
'link': row[link_col]
#'category': ',
})
# write gavel file (to paste to gavel)
with open(output_gavel_path, 'w') as csvfile:
fieldnames = ['project', 'location', 'description']
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
writer.writeheader()
for row in gavel:
writer.writerow(row)