-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimportTable.py
More file actions
69 lines (60 loc) · 2.17 KB
/
importTable.py
File metadata and controls
69 lines (60 loc) · 2.17 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
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
60
61
62
63
64
65
66
67
68
69
"""
importTable
read google sheet and create the appropriate object for each person
"""
from person import Person
import pandas as pd
import math
class ImportTable:
def __init__(self, path):
self.path = path
def fetchTable(self, path):
self.df = pd.read_excel(path, engine = "openpyxl")
return self.df
def processTable(self, df):
# list of sailors where objects will be iteratively added
sailors = []
for index, row in df.iterrows():
email = row['Email Address']
name = row['Name']
cell = self.cellNumberProcess(str(row['Cell number']))
# process information how many they can take to practice
peopleCanDrive = row['How many people can you drive to practice including yourself?']
if peopleCanDrive == "None":
peopleCanDrive = 0
elif peopleCanDrive == "Only myself":
peopleCanDrive = 1
elif peopleCanDrive == "More than 5":
peopleCanDrive = 6
else:
# check if it's a float NaN
if pd.isna(peopleCanDrive):
peopleCanDrive = 0
else:
peopleCanDrive = int(peopleCanDrive)
location = row['Pickup Location']
# some people have made comments, some have not
# first of all check if the comment column still exists
comment = ""
try:
comment = row['Anything else we should know?']
except:
# it doesnt exist
comment = "Null"
try:
math.isnan(row['Anything else we should know?'])
comment = "Null"
except:
pass
thisPerson = Person(email, name, cell, peopleCanDrive, location, comment)
sailors.append(thisPerson)
return sailors
"""
cellNumberProcess
they should be in a certain format
"""
def cellNumberProcess(self,number):
newNumber = number
if number[0] != "+":
newNumber = "+1"+ str(newNumber).split('.')[0]
return newNumber