Q:

Save AWS API output as CSV getting TypeError as NoneType or Blank

 **COLUMN A**                                                 **COLUMN B**

[{TimePeriod: {Start: 2020-03-01    
 End: 2020-04-01}   

I have a script that pulls data from AWS. AWS automatically puts in the info with the data when running this command. How do I get just the amount from column A and have it look like Column B? Column B is my manual input and Column A is from AWS output. Is there something I can add to my script to only output the Amount?

A:

Replace:
    results += data['ResultsByTime']

With:
    for info in data['ResultsByTime']:
        for group in info['Groups']:
            results.append(float(group['Metrics']['AmortizedCost']['Amount']))

If you simply wish to print the results, and include the Linked Account, use:
    for info in data['ResultsByTime']:
        for group in info['Groups']:
            print(group['Keys'][0], group['Metrics']['AmortizedCost']['Amount'])

To also show the dates:
    for info in data['ResultsByTime']:
        for group in info['Groups']:
            print(group['Keys'][0], info['TimePeriod']['Start'], info['TimePeriod']['End'], group['Metrics']['AmortizedCost']['Amount'])

