Mar-28-2017, 05:25 PM
For #1, just slice it off:
>>> fname = "something.json.bz2" >>> ".bz2" == fname[-4:] True >>> fname[:-4] 'something.json'