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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.