You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: vtools/functions/read_dss.py
+44-38Lines changed: 44 additions & 38 deletions
Original file line number
Diff line number
Diff line change
@@ -47,51 +47,57 @@ def read_dss(
47
47
----------
48
48
filename: str|Path
49
49
Path to the DSS file to read
50
-
pathname: str
51
-
Pathname within the DSS file to read.
50
+
pathname: str|list
51
+
Pathname(s) within the DSS file to read.
52
52
Needs to be in the format '/A_PART/B_PART/C_PART/D_PART/E_PART/F_PART/'
53
53
(e.g. '//RSAN112/FLOW////')
54
54
"""
55
55
ts_out_list= []
56
56
col_names= []
57
-
print(f"\tReading pathname: {pathname}")
58
-
iflen(pathname.split("/")[1:-1]) !=6:
59
-
raiseValueError(f"Invalid DSS pathname: {pathname}, needs 6 parts (A-F)")
60
-
ts=get_ts(str(filename), pathname)
61
-
fori, tsiinenumerate(ts):
62
-
ts_path=tsi[0].columns.values[0]
63
-
ifexclude_pathnameisNoneor (
64
-
exclude_pathnameisnotNone
65
-
andnotcheck_exclude(ts_path, exclude_pathname)
66
-
):
67
-
# if not an excluded path, then carry on
68
-
path_lst= (ts_path).split("/")
69
-
path_e=path_lst[5]
70
-
# Set default start_date and end_date to cover the full period of record if not specified
71
-
tt_full=tsi[0]
72
-
ifstart_dateisNone:
73
-
start_date=tt_full.index[0].to_timestamp()
74
-
ifend_dateisNone:
75
-
end_date=tt_full.index[-1].to_timestamp()
76
-
iftt_full.index[0].to_timestamp() >end_dateor (
77
-
tt_full.index[-1].to_timestamp() <start_date
57
+
ifisinstance(pathname, str):
58
+
pathname= [pathname]
59
+
forpathinpathname:
60
+
iflen(path.split("/")[1:-1]) !=6:
61
+
raiseValueError(f"Invalid DSS path: {path}, needs 6 parts (A-F)")
62
+
ts=get_ts(str(filename), *pathname)
63
+
forpathinpathname:
64
+
print(f"\tReading path: {path}")
65
+
fori, tsiinenumerate(ts):
66
+
ts_path=tsi[0].columns.values[0]
67
+
ifexclude_pathnameisNoneor (
68
+
exclude_pathnameisnotNone
69
+
andnotcheck_exclude(ts_path, exclude_pathname)
78
70
):
79
-
raiseValueError(
80
-
f"File: {filename} does not cover the dates requested. \n\tRequested dates are: {start_date} to {end_date}, \n\tand the file covers {tt_full.index[0]} to {tt_full.index[-1]}"
71
+
# if not an excluded path, then carry on
72
+
path_lst= (ts_path).split("/")
73
+
path_e=path_lst[5]
74
+
# Set default start_date and end_date to cover the full period of record if not specified
75
+
tt_full=tsi[0]
76
+
ifstart_dateisNone:
77
+
start_date=tt_full.index[0].to_timestamp()
78
+
ifend_dateisNone:
79
+
end_date=tt_full.index[-1].to_timestamp()
80
+
iftt_full.index[0].to_timestamp() >end_dateor (
81
+
tt_full.index[-1].to_timestamp() <start_date
82
+
):
83
+
raiseValueError(
84
+
f"File: {filename} does not cover the dates requested. \n\tRequested dates are: {start_date} to {end_date}, \n\tand the file covers {tt_full.index[0]} to {tt_full.index[-1]}"
0 commit comments