-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.py
47 lines (33 loc) · 1 KB
/
lib.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
import csv
import pandas as pd
def log_info(msg):
print(msg)
def pp(df):
with pd.option_context('display.max_rows', None, 'display.max_columns', None):
pd.set_option('display.expand_frame_repr', False)
print(df)
def make_gen_csv(csv_file):
def gen_tuple():
with open(csv_file, 'r') as f:
for t in csv.reader(f, delimiter=',', quotechar='"'):
yield t
return gen_tuple()
def make_is_not(f_filter):
def is_not(table):
return not f_filter(table)
return is_not
def make_is_in(table_names):
def is_in(table):
if table.name in table_names: return True
else: return False
return is_in
def make_is_not_in(table_names):
def is_not_in(table):
if table.name not in table_names: return True
else: return False
return is_not_in
def make_filter_tables(f_filter):
def apply_filter(tables):
return [table for table in tables
if f_filter(table)]
return apply_filter