Hello, I hope you are well:
I am currently testing to see how Cloud Functions works.
I want to do a process where I take a csv file that I uploaded to Cloud Storage.
I modify it, and I want to place the modified file new in Storage.
I do it using this code:
from google.cloud import storage
def Carga():
Descargar el archivo CSV del bucket
client = storage.Client()
bucket = client.get_bucket(‘alvaro-prueba’)
blob = bucket.blob(‘name.csv’)
content = blob.download_as_string()
Modificar las columnas 1 y 2
df = pd.read_csv(io.StringIO(content.decode(‘utf-8’)))
df[‘column1’] = df[‘column1’].str.upper()
df[‘column2’] = df[‘column2’].str.replace(‘a’, ‘X’)
Subir el archivo CSV modificado al bucket
blob_modificado = bucket.blob(‘name_modificado.csv’)
blob_modificado.upload_from_string(df.to_csv(index=False), content_type=‘text/csv’)
Cloud Functions checks me green Check. But when I look for the file modified to bucket in Cloud Storage it is not there.
I used 1st gen