hlukes / gpx-renamer

2 stars 0 forks source link

GPXXMLSyntaxException #1

Closed doc-sebastian closed 1 year ago

doc-sebastian commented 1 year ago

Dear hlukes,

Thank you for this nice script! It works fine for the first file in my "input" folder, but stops working for the next files while throwing this error:

raise mod_gpx.GPXXMLSyntaxException('Error parsing XML: %s' % str(e), e) gpxpy.gpx.GPXXMLSyntaxException: Error parsing XML: unbound prefix: line 37, column 5

Do you have any idea what the problem could be? I already tried different GPX-Files and a linux and windows enviroment, as well as python2 and python3, but nothing seemed to work.

Thank you so much, this script seems to be the perfect solution for organizing GPX-Files!

hlukes commented 1 year ago

Hello, thanks for checking my script.

I will look into the error deeper when I get a chance. I had no problems with my test GPX files, but they were just from a few sources. The error is raised by the gpxpy parser, which could mean the problem is with either the gpx files or gpxpy, however I will try to solve it in the script. It would help if youcould provide some of the failing GPX files, or at least the part around line 37. One thing you could try is removing the encoding specification on line 152 in standalone gpx_file = open(in_path_file, 'r', encoding='utf-8') so it looks like this: gpx_file = open(in_path_file, 'r')

I haven't tested it yet, but will try to help you soon. Have a good, hlukes.

doc-sebastian commented 1 year ago

Dear hlukes,

I checked different GPS-Files and most of the files worked fine. Attached are two files, which do not work and make the script stop working. When I delete the mishandled files from the input folder I can start the process of renaming again.

Some more aspects:

1) When using %ts or %te the output generates a format "hour:minute" but ":" is not an allowed character for file names.

2) I saw your program code for adding a trailing "0" for month and day numbers <10 but at least for me the numbers of the output stay with only one character in length.

3) Living in germany I added some more special-characters (probably worth adding them):

_whitelist = set(string.asciiletters + string.digits + "!-()#ÄäÜüÖößèěščřžýáíéĚŠČŘŽÝÁÍÉÚŮúůťď∶ ")_

Best regards and thank you for this super cool script which allowed me to rename almost 20.000km of GPX bike logs in a batch.

Sebastian

Hello, thanks for checking my script.

I will look into the error deeper when I get a chance. I had no problems with my test GPX files, but they were just from a few sources. The error is raised by the gpxpy parser, which could mean the problem is with either the gpx files or gpxpy, however I will try to solve it in the script. It would help if youcould provide some of the failing GPX files, or at least the part around line 37. One thing you could try is removing the encoding specification on line 152 in standalone gpx_file = open(in_path_file, 'r', encoding='utf-8') so it looks like this: gpx_file = open(in_path_file, 'r')

I haven't tested it yet, but will try to help you soon. Have a good, hlukes.

-- Reply to this email directly, view it on GitHub [1], or unsubscribe [2]. You are receiving this because you authored the thread.Message ID: @.***>

Links:

[1] https://github.com/hlukes/gpx-renamer/issues/1#issuecomment-1302687736 [2] https://github.com/notifications/unsubscribe-auth/AKJTB7OHJOFNVE66HOEHIMDWGQVTTANCNFSM6AAAAAARURU5OA

hlukes commented 1 year ago

Dear Sebastian,

Thanks for the feedback. For your points: 1) - Im actually using a very similar character "∶" (ratio). It should work fine in file names, but if you have any problems, let me know. 2) - I had this code for minutes, but I will add it for months as well in the next week or so. 3) - I will add the german special characters as well as some other that someone else could use, I never thought about it before. Thank you for bringing that up.

As for the original problem, I believe the best solution is just catching any exceptions raised while opening the file and handle it further so it doesnt crash the entire script.

I will add in the changes as soon as I will have a chance, should be in a week or so.

If you have any other suggestions (btw, I will be switching everything to english soon) let me know. Have a nice day and thanks again for the feedback.

hlukes

doc-sebastian commented 1 year ago

Dear hlukes, Thank you and lots of Kudos for this nice script!!

Am 12. November 2022 18:41:40 schrieb hlukes @.***>:

Dear Sebastian,

Thanks for the feedback. For your points: 1) - Im actually using a very similar character "∶" (ratio). It should work fine in file names, but if you have any problems, let me know. 2) - I had this code for minutes, but I will add it for months as well in the next week or so. 3) - I will add the german special characters as well as some other that someone else could use, I never thought about it before. Thank you for bringing that up.

As for the original problem, I believe the best solution is just catching any exceptions raised while opening the file and handle it further so it doesnt crash the entire script.

I will add in the changes as soon as I will have a chance, should be in a week or so.

If you have any other suggestions (btw, I will be switching everything to english soon) let me know. Have a nice day and thanks again for the feedback.

hlukes

-- Reply to this email directly or view it on GitHub: https://github.com/hlukes/gpx-renamer/issues/1#issuecomment-1312536090 You are receiving this because you authored the thread.

Message ID: @.***>

hlukes commented 1 year ago

Dear Sebastian, I hopefully adressed most of the recommendations you had in this issue in this branch:

https://github.com/hlukes/gpx-renamer/tree/issue-development-gpxxmlsyntaxexception

I was not able to solve the issue you were having without the specific files, but I did add code that should at least tell you what has gone wrong when opening the file more accurately. I also changed the whitelist and included code to add a starting 0 for months and days smaller than 10. It might still have a few bugs and I need to add some common exceptions for the opening try catch statement, but I hope this helps.

Have a nice day,

hlukes