Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3 issue - 'filter' object has no attribute 'sort' #1

Closed
BjGoCraft opened this issue May 19, 2023 · 2 comments
Closed

Python 3 issue - 'filter' object has no attribute 'sort' #1

BjGoCraft opened this issue May 19, 2023 · 2 comments

Comments

@BjGoCraft
Copy link

When I try to execute the script with Python 3.10.6 I get the error message
'filter' object has no attribute 'sort'
I found this other issue that points out changes in python 3 that caused this issue:
raghakot/keras-text#9
But I'm new to python and can't fix this/propose a solution. Would be glad if you'd update your project :)

@vicbab
Copy link

vicbab commented Mar 6, 2024

I found a fix for that. You are probably merging gpx files without timestamps. You can comment lines 47 and 49 and it will work.

# 2. Remove trkpts without timestamp
track_segment = filter(lambda trkpt: trkpt.time is not None, track_segment)
# 3. Sort trkpts chronologically
track_segment.sort(key=lambda trkpt: trkpt.time)

@BjGoCraft
Copy link
Author

By now I learned python and wrote my own python script for my use case :D
Nevertheless I tried your fix. It kinda worked. I don't get the error anymore and I get usable gpx data except when using gpx-tracks recorded with OsmAND. They can't be opened by any program. Their trackpoints look like this:

<trkpt lat="9.5520863" lon="49.6756989">
        <ele>16.9</ele>
        <time>2023-05-20T12:43:19Z</time>
        <hdop>3.9</hdop>
        <extensions>
          <osmand:bearing>14.8</osmand:bearing>
          <osmand:speed>9.6</osmand:speed>
          <osmand:heading>0</osmand:heading>
        </extensions>
   </trkpt>

Maybe it has something to do with the 'osmand' in the extension's name, I don't know. But this is an edge case I don't want to spend more time with since my script only uses the coordinate part of the trackpoints. Also I don't understand why commenting these lines worked since all my gpx files do have timestamps.
Anyway thanks for the help :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants