-
Notifications
You must be signed in to change notification settings - Fork 34
/
dataLoaderUtils.py
33 lines (27 loc) · 988 Bytes
/
dataLoaderUtils.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
###############################
# Helper functions for Data Loaders
###############################
import os
class dataLoaderUtils:
"""
params : filename - name of the file to read
returns : list of lines after striping '\n'
(new line charcater) from the end.
"""
@staticmethod
def readLines(filename):
assert (os.path.isfile(os.path.join("data", filename))), " File:" + filename + " does not exists"
if os.path.isfile(os.path.join("data", filename)):
print("file exists")
lines = open(os.path.join("data", filename)).read().splitlines()
return lines
"""
params : path - location of the directory
Create a directory at the path specified if it doesnot
already exists.
"""
@staticmethod
def mkdir(path):
#assert (os.path.isfile(path)), " dir already exists"
if not os.path.isdir(path):
os.mkdir(path)