Q:

Issue with tarfile and invalid header error

I have a tarfile from http://download.geofabrik.de/africa/botswana-latest.osm.bz2
When I save the file to disk and use the Python tarfile library to extract the .osm file, I get an invalid header error.
Is there a way around this error?
7zip can open the file and extract the data without an issue but I need to script the extraction of the data.

A:

Thats not a tarfile!  It's a flat file compressed with bzip2.  You can use the python bz2 standard module to interact with files that are compressed with bzip2.

