0

I am working on a script that downloads RINEX observation data from NASA (https://cddis.nasa.gov/Data_and_Derived_Products/GNSS/daily_30second_data.html) and I can't decompress it with the gzip module.

However, I can successfully decompress it by running gzip -d <file> in the shell.

The error message seems to point that the file's magic number is invalid:

OSError: Not a gzipped file (b'\x1f\x9d')

I am using subprocess right now to invoke gzip but it would be very nice if I could just use the gzip module. Does anyone knows if it is a problem with the data or just a limitation of the module?

Fabio Picchi
  • 1,202
  • 2
  • 10
  • 22
  • Your question really should include your current code so we don't have to guess how exactly you are producing this error. – tripleee Mar 27 '19 at 09:11
  • 1
    0x1f 0x9d indicates a `.Z` (`compress`) file, not a `.gz` file. The `gzip` utility can handle both formats for convenience (it probably simply does `exec compress -d` internally) but of course, when dealing with things programmatically, you don't want "do what I mean" behavior because that can lead to nasty surprises; and the Python `gzip` library is only capable of handling genuine `.gz` format. – tripleee Mar 27 '19 at 09:18
  • Thanks! I tried to look for this magic number but I couldn't find any information about it online. Thank you very much for your explanation, I marked my question as a duplicate – Fabio Picchi Mar 27 '19 at 09:38
  • 1
    Simply googling "1f-9d magic-number" is what gave me the link to the Wikipedia page which is also linked in the duplicate. – tripleee Mar 27 '19 at 09:53
  • My searches were like this: 1f9d magic number gzip 1f9d magic number I don't know why 1f-9d yields proper results while 1f9d doesn't but thanks for sharing your search strings. I will look into how these strings are processed by the search engines to better understand them. I am sorry for the trouble :( – Fabio Picchi Mar 27 '19 at 10:12
  • Absolutely no worries, we are all here to learn! – tripleee Mar 27 '19 at 10:26

0 Answers0