Tradingeconomics wants you to pay a ridiculous amount for the privilege of exporting public data as csv.

Their site obtains economic data from some api in base64, gzip and XOR encrypted form. I (kinda, got help from Chatgpt) made a script to decrypt and convert data to a readable excel sheet.

https://pastebin.com/raw/gxXZnN37

  • ZWQbpkzl [none/use name]
    ·
    2 months ago

    Few notes:

    • there's an isoformat method you can use instead of manually specifying the iso format for dates.
    • lol at that api-key key.
    • replace if good; return happy; else; return sad with if bad; return sad; return happy. Its easier to read and saves you some indents. It might offend functional programmers but this is python.
    • pandas is a huge dep and all your using it for is to make an xlsx. If you used CSV it all be standard python and the script would be more portable.

    Critiquing because its otherwise really good. Slap some argparsing on top. If you want to do bulk downloads look into asyncio and httpx.

    • GaveUp [she/her]
      ·
      edit-2
      2 months ago

      replace if good; return happy; else; return sad with if bad; return sad; return happy. Its easier to read and saves you some indents

      I will forever hate whatever bazinga wrote this into whatever style guide that has this opinion. The first is way easier imo, it's explicit that if this happens, then return this, if anything else, return that. The latter you have to fill in a tiny gap when reading to put in the inferred else clause that's not written down to figure it out

      Regardless, if I wanted to be an asshole for work politics in this situation I'd comment "aKScHuaLLy return happy if good else sad is better"