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

.tcx file: ParseError: XML or text declaration not at start of entity #99

Open
roboes opened this issue Mar 8, 2022 · 1 comment
Open

Comments

@roboes
Copy link

roboes commented Mar 8, 2022

I am having the following problem with .tcx files:

ParseError: XML or text declaration not at start of entity: line 1, column 10

Seems that all my .tcx files have 10 blank spaces before the <?xml argument.

Is there any possible workaround for reading such .tcx files?

Here's an example: test.txt (file extension was changed to .txt due to GitHub limitations and needs to be changed to .tcx).

Thanks!

@roboes
Copy link
Author

roboes commented Mar 18, 2022

I have found a workaround to solve this issue: open all .tcx files from a given folder and remove (if any) leading blank spaces from the first row:

## Remove leading first line blank spaces of .tcx activity files
def tcx_lstrip():
    
    ## List of .tcx files to be imported
    activities_files_list = glob.glob(r'activities/*.tcx')
    
    ## Remove leading spaces from first row
    for index in activities_files_list:
    
        with open(file=index, mode='r') as f:
            lines = f.readlines()
            lines[0] = lines[0].lstrip()

        with open(file=index, mode='w') as f:
            f.writelines(lines)

This workaround was implemented in my strava-local-heatmap-tool script.

Still a native solution (without modifying the original .tcx file) would be ideal.

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

1 participant