0

i am trying to copy the file from local drive to gcp cloud storage using python code as written below but I am getting the below file not found error.

FileNotFoundError: [Errno 2] No such file or directory: 'C:/Users//vithal//test.csv'

'''

from google.cloud import storage
import os
#pip install --upgrade google-cloud-storage.
def upload_to_bucket(landing_bucket_name):
  storage_client = storage.Client()
  project_id = 'abc'
  dataset_id = 'xyz'
  landing_bucket_name = '123'
  landing_blob_name = 'test_upload'
  local_path = "C://Users//test.csv"


#print(buckets = list(storage_client.list_buckets())

  bucket = storage_client.get_bucket(landing_bucket_name)  

  blob = bucket.blob(landing_blob_name)
  blob.upload_from_filename(local_path)


#returns a public url
  return blob.public_url

'''

vithal n
  • 11
  • 6
  • Have you referred to this links: http://net-informations.com/python/err/path.htm and https://stackoverflow.com/questions/22282760/filenotfounderror-errno-2-no-such-file-or-directory – Sandeep Vokkareni Jun 24 '22 at 13:12

1 Answers1

0

Are you sure there is a file there? It's a very strange place to store a file!

I'd expect the path to be more like c:/Users/vithaln/test.csv

Mesh
  • 6,262
  • 5
  • 34
  • 53
  • thanks Mesh, just for example i have given like that, but the path is like that only. please suggest – vithal n Jun 23 '22 at 14:07
  • @vithaln - since the error is about the source file, show the actual source file details in your question. – John Hanley Jun 23 '22 at 18:23
  • @JohnHanley the source file is nornal csv file only , but the python code written in gcp is not reading the file and not even the path. Please suggest – vithal n Jun 24 '22 at 05:26