0

How to read and update a field in JSON file that's in Google cloud using Python script. I've tried using

with open(filepath, 'r')

Where filepath was a gs path location

gs://bucket-name/path

But I was getting FileNotFoundError. Is there any other way to read and update a field in JSON that's in Google cloud using Python?

Chithal
  • 59
  • 5
  • If you want to read a file you need to use google cloud storage library.Have a look at this [document](https://cloud.google.com/appengine/docs/legacy/standard/python/googlecloudstorageclient/read-write-to-cloud-storage#reading_from) – Sathi Aiswarya Feb 01 '23 at 07:26
  • Hi @Chithal Glad to hear that it was helpful. I shared my comment as a solution, so that it would be easier to find for others who are facing the same issue.please consider accpeting or upvoting:) – Sathi Aiswarya Feb 03 '23 at 08:23

1 Answers1

1

If you want to read or write a file you will need to use Google Cloud Storage library. The Google Cloud Storage library is a client library for accessing Google Cloud Storage services. This library provides several methods to interact with objects in Cloud Storage,which also includes methods for reading and updating the objects.

You can check this document on Reading and writing to Cloud Storage for more information and code samples.

Also check the below similar example

How to Read .json file in python code from google cloud storage bucket

Sathi Aiswarya
  • 2,068
  • 2
  • 11