-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgeneralFuncs.py
More file actions
36 lines (25 loc) · 844 Bytes
/
generalFuncs.py
File metadata and controls
36 lines (25 loc) · 844 Bytes
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
#!/usr/bin/python3
import errno
import fnmatch
import os
import pandas as pd
def getCsv(filename):
with open(filename, 'r') as SP1074csv:
return pd.read_csv(SP1074csv)
def getHdfGroups(filename):
if not os.path.isfile(filename):
raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), filename)
with pd.HDFStore(filename) as file:
return list(file.keys())
def getArbitraryDictItem(d):
return next(iter(d.values()))
def deleteHdfGroups(filename, pattern):
with pd.HDFStore(filename) as file:
groups = list(file.keys())
groupsToRemove = fnmatch.filter(groups, pattern)
with pd.HDFStore(filename) as file:
for groupToRemove in groupsToRemove:
file.remove(groupToRemove)
def reloadModule(module):
import importlib
importlib.reload(module)