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

Remove waypoint while in loop? #236

Closed
Shohreh opened this issue Aug 18, 2021 · 1 comment
Closed

Remove waypoint while in loop? #236

Shohreh opened this issue Aug 18, 2021 · 1 comment

Comments

@Shohreh
Copy link

Shohreh commented Aug 18, 2021

Hello,

I went through the test.py, but didn't find if it's possible.

I was wondering if gpxpy provides a way to remove a waypoint from the array while in a loop:

import gpxpy
import gpxpy.gpx

stations_file = open("input.gpx", mode='rt', encoding='utf-8')
stations_gpx = gpxpy.parse(stations_file)
stations_file.close()
print("Number of stations: ",len(stations_gpx.waypoints))

for waypoint in stations_gpx.waypoints:
	if waypoint.name = "Dummy":
		#How to remove waypoint from array?

Thank you.

@tkrajina
Copy link
Owner

stations_gpx.waypoints is a normal list. You remove an item like you remove an item from any other list. For example with filter:

>>> l = [1, 2, 3, 4, 5, 6, 7, 8]
>>> list(filter(lambda e: e % 2 == 0, l))
[2, 4, 6, 8]

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