简体   繁体   中英

upload .gpx file Streamlit Python

I've made a Streamlit app using python, in which it is possible to drag and drop a gpx file.

import streamlit as st 
file = st.file_uploader("Upload a strava file (gpx)", type=["gpx"],accept_multiple_files=False)

在此处输入图像描述

However opening the InMemoryUploadedFile with the package gpxpy package isn't possible. Giving me a KeyError: 3655

import gpxpy
gpx = gpxpy.parse(file)

Can someone help me?

Please try:

import streamlit as st
import gpxpy

file = st.file_uploader("Upload a strava file (gpx)", type=["gpx"], accept_multiple_files=False)

if uploaded_file is not None:
    gpx = gpxpy.parse(uploaded_file)

Please also make sure both streamlit and gpxpy is updated to the latest version and the gpx file is not corrupted

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM