Python code that transforms JSON input into CSV output