I have been using Streamlit to build a LAS file explorer, however, I am encountering issues when I try to load the file in my app. LAS files are used in the Oil & Gas industry to store well log data and they are essentially ASCII files with a unique header on top. These files can be read using the lasio library: https://lasio.readthedocs.io/en/latest/
When the app is first run (either locally or on Heroku) and I select a file using the file_uploader, all appears well until I go to another page in the app to view the data. When I do this I get an IndexError: list index out of range. I have copied the traceback below for reference.
I then click on Browse again and reselect the file. When I do this, all appears to be fine when working with the uploaded file. It continues to work until I close the browser tab and reload the app using
streamlit run app.py
I have tried to debug the code using debugpy and VSCode, but I am going around in circles with errors relating to ports (ECONNREFUSED and ERROR No 48) so I have been unable to debug and work out if the issue is in lasio or Streamlit or my code.
Would anyone be able to offer any advice or help on this issue please? It’s driving me round the bend a little
My app is hosted here:
Live Code used by Heroku:
An example LAS file can be found in my testing branch for this repo under the data folder.
IndexError: list index out of range
File "/anaconda3/lib/python3.6/site-packages/streamlit/script_runner.py", line 332, in _run_script exec(code, module.__dict__)File "/Users/andy/Documents/Python_Projects/LASExplorer/app.py", line 50, in <module> las_file, well_data = load_data(uploadedfile)File "/anaconda3/lib/python3.6/site-packages/streamlit/caching.py", line 591, in wrapped_func return get_or_create_cached_value()File "/anaconda3/lib/python3.6/site-packages/streamlit/caching.py", line 575, in get_or_create_cached_value return_value = func(*args, **kwargs)File "/Users/andy/Documents/Python_Projects/LASExplorer/app.py", line 24, in load_data las_file = lasio.read(string)File "/anaconda3/lib/python3.6/site-packages/lasio/__init__.py", line 41, in read return LASFile(file_ref, **kwargs)File "/anaconda3/lib/python3.6/site-packages/lasio/las.py", line 77, in __init__ self.read(file_ref, **read_kwargs)File "/anaconda3/lib/python3.6/site-packages/lasio/las.py", line 113, in read file_obj, self.encoding = reader.open_file(file_ref, **kwargs)File "/anaconda3/lib/python3.6/site-packages/lasio/reader.py", line 70, in open_file first_line = lines