forked from alextenney/InformationSecurityClubDatabaseAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsqlize.py
More file actions
32 lines (24 loc) · 1.14 KB
/
Copy pathsqlize.py
File metadata and controls
32 lines (24 loc) · 1.14 KB
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
# Author: Martha Ibarra
# Contributers:
# Date Updated: April 12, 2020
# Description: This is a python program to convert actual club attendance data and participants into sql queries.
#Name,Email,UCID,Meetings Attended,Member Status,,Name,Email,UCID,Meetings Attended,Member Status
#desired format: INSERT INTO participants (name, email, UCID, meetingsAttended) VALUES ('Alexandra Tenney','alexandra.tenney@ucalgary.ca','30042397','8');
#this program will correctly put sql data into correct insert data
def sqlize(member):
memarr = member.split(",")
length = len(memarr) - 1 #ignoring score
formatted = 'INSERT INTO participants (name, email, UCID, meetingsAttended) VALUES ('
for i in range(length):
memarr[i] = '\"' + memarr[i] + '\"'
if i == length-1:
formatted = formatted + memarr[i]
else:
formatted = formatted + memarr[i] + ","
formatted = formatted + ");"
return formatted
#memstr=input('Enter string: ')
with open("participant_data.txt", "r") as a_file:
for line in a_file:
stripped_line = line.strip()
print(sqlize(stripped_line))