0

Hello is it possible to open a file from google cloud storage and write to it?

request = requests.get(f'https://api.sportsdata.io/v3/nba/scores/json/TeamSeasonStats/2022?key=')

nba_team_stats = request.json()

# Cloud Storage (Connect to Cloud Storage)
data_file = open('nba_team_stats.csv', 'w')

csv_writer = csv.writer(data_file)

count = 0

for stats in nba_team_stats:
    if count == 0:
        header = stats.keys()
        csv_writer.writerow(header)
        count += 1
    csv_writer.writerow(stats.values())
data_file.close()

this is my code that opens and writes and file in my local machine however how can I do the same thing with cloud function and cloud storage?

tryingToBeBetter
  • 365
  • 1
  • 6
  • 16
  • 1
    What question do you have that these comments don't address? https://stackoverflow.com/questions/70440659/using-google-cloud-function-python-to-save-csv-to-cloud-storage – Chris J Dec 21 '21 at 21:31
  • Cloud Functions requires a specific signature to be invoked. The size of the file that you can handle is limited by the memory size of your Cloud Functions (because all the data are stored in database.) – guillaume blaquiere Dec 22 '21 at 09:01

0 Answers0