gpxplotter icon indicating copy to clipboard operation
gpxplotter copied to clipboard

Replaced gpx file -> "ValueError: I/O operation on closed file"

Open eusoj opened this issue 3 years ago • 0 comments

(Using Windows and Jupyter lab)

  1. Used gpxplotter with a file and this code:

gpx_file = "example1.gpx" from gpxplotter import read_gpx_file, create_folium_map, add_segment_to_map line_options = {'weight': 8}

the_map = create_folium_map(tiles='openstreetmap') for track in read_gpx_file(gpx_file): for i, segment in enumerate(track['segments']): add_segment_to_map(the_map, segment, color_by='velocity-level', cmap='RdPu_09', line_options=line_options)

It worked fine.

  1. Then, I did this unique replacement: gpx_file = "example2.gpx" Since, It gives me this error which doesn't disappear anymore:

ValueError Traceback (most recent call last) Input In [4], in <cell line: 5>() 2 line_options = {'weight': 8} 4 the_map = create_folium_map(tiles='openstreetmap') ----> 5 for track in read_gpx_file(gpx_file): 6 for i, segment in enumerate(track['segments']): 7 add_segment_to_map(the_map, segment, color_by='velocity-level', 8 cmap='RdPu_09', line_options=line_options)

File ~\AppData\Local\Programs\Python\Python310\lib\site-packages\gpxplotter\gpxread.py:352, in read_gpx_file(gpxfile, max_heart_rate) 335 def read_gpx_file(gpxfile, max_heart_rate=187): 336 """Read data from a given gpx file. 337 338 Parameters (...) 350 351 """ --> 352 gpx = minidom.parse(gpxfile) 353 tracks = gpx.getElementsByTagName('trk') 354 for track in tracks:

File ~\AppData\Local\Programs\Python\Python310\lib\xml\dom\minidom.py:1988, in parse(file, parser, bufsize) 1986 if parser is None and not bufsize: 1987 from xml.dom import expatbuilder -> 1988 return expatbuilder.parse(file) 1989 else: 1990 from xml.dom import pulldom

File ~\AppData\Local\Programs\Python\Python310\lib\xml\dom\expatbuilder.py:913, in parse(file, namespaces) 911 result = builder.parseFile(fp) 912 else: --> 913 result = builder.parseFile(file) 914 return result

File ~\AppData\Local\Programs\Python\Python310\lib\xml\dom\expatbuilder.py:204, in ExpatBuilder.parseFile(self, file) 202 try: 203 while 1: --> 204 buffer = file.read(16*1024) 205 if not buffer: 206 break

ValueError: I/O operation on closed file.

eusoj avatar Sep 02 '22 11:09 eusoj