-
Notifications
You must be signed in to change notification settings - Fork 0
/
module.py
45 lines (40 loc) · 1.36 KB
/
module.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
from config import bucket
import re
import pandas as pd
import io
import os
def check(s):
regex = re.compile(r"([-!#-'*+/-9=?A-Z^-~]+(\.[-!#-'*+/-9=?A-Z^-~]+)*|\"([]!#-[^-~ \t]|(\\[\t -~]))+\")@([-!#-'*+/-9=?A-Z^-~]+(\.[-!#-'*+/-9=?A-Z^-~]+)*|\[[\t -Z^-~]*])")
if re.fullmatch(regex,s):
return s
else:
return None
def read_suggests():
data = pd.read_csv(
io.BytesIO(
bucket.blob(blob_name = "suggests.csv").download_as_bytes()
),
index_col = 0, encoding = 'utf-8'
)
return data
def read_final():
data = pd.read_csv(
io.BytesIO(
bucket.blob(blob_name = "final.csv").download_as_bytes()
),
index_col = 0, encoding = 'utf-8'
)
return data
def read_usertemp(username):
data = pd.read_csv(
io.BytesIO(
bucket.blob(blob_name = f"user_temps/temp_{username}.csv").download_as_bytes()
),
index_col = 0, encoding = 'utf-8'
)
return data
def upload(filename):
UPLOADFILE = os.path.join(os.getcwd(),filename)
blob = bucket.blob(filename)
blob.upload_from_filename(UPLOADFILE)
return True