File tree Expand file tree Collapse file tree 1 file changed +25
-8
lines changed
src/segmentation_skeleton_metrics/utils Expand file tree Collapse file tree 1 file changed +25
-8
lines changed Original file line number Diff line number Diff line change @@ -133,22 +133,21 @@ def list_paths(directory, extension=None):
133133
134134
135135# --- IO Utils ---
136- def read_zip ( zip_file , path ):
136+ def read_json ( path ):
137137 """
138- Reads a txt file contained in the given ZIP archive .
138+ Reads JSON file located at the given path .
139139
140140 Parameters
141141 ----------
142- zip_file : ZipFile
143- ZIP archive containing TXT file.
142+ path : str
143+ Path to JSON file to be read .
144144
145145 Returns
146146 -------
147- str
148- Contents of a TXT file.
147+ dict
148+ Contents of JSON file.
149149 """
150- with zip_file .open (path ) as f :
151- return f .read ().decode ("utf-8" )
150+ return pd .read_json (path , storage_options = {"anon" : True }, typ = "series" )
152151
153152
154153def read_txt (path ):
@@ -174,6 +173,24 @@ def read_txt(path):
174173 return f .read ().splitlines ()
175174
176175
176+ def read_zip (zip_file , path ):
177+ """
178+ Reads txt file contained in the given ZIP archive.
179+
180+ Parameters
181+ ----------
182+ zip_file : ZipFile
183+ ZIP archive containing TXT file.
184+
185+ Returns
186+ -------
187+ str
188+ Contents of a TXT file.
189+ """
190+ with zip_file .open (path ) as f :
191+ return f .read ().decode ("utf-8" )
192+
193+
177194def update_txt (path , text , verbose = True ):
178195 """
179196 Appends the given text to a specified text file and prints the text.
You can’t perform that action at this time.
0 commit comments