0
votes

I have a JSON file customer_records.json in a Google Cloud Storage bucket called sales_data.

In a Python file, I have the following list:

metrics_map = [{"State": "Austin", "City": "Texas"}, {"State": "New York", "City": "New York"}]

How can I upload this list into a Google Cloud Storage bucket and overwrite the customer_records.json file?

I tried to use blob.upload_from_file(metrics_map), but this command does not take a list object.

1

1 Answers

1
votes

You can use blob.upload_from_string to upload serialized JSON. See the Python Docs or Uploading Objects Docs and search for upload_from_string. You can use json.dumps(metrics_map) to create a string from your JSON.