how to convert backslash to forward slash in path name on gcp using python

39 Views Asked by At

while copying the file path from local to Google Cloud Platform, the path at local is in retail_db\categories\part-00000 format whereas GCP is accepting format as retail_db/categories/part-00000

I have successfully copied the path to GCP but it is showing like this: gs://kiretail/pythondemo/retail_db\categories\part-00000

How to replace this backward slash with forward slash?

tried using this:

path.replace("\\", "/")

But still I am missing something. Below is the code to copy filepath to gcp:

files = filter(lambda item: os.path.isfile(item), items)
bucket = gsclient.get_bucket('kiretail')
for file in files:
print(f'Uploading file {file}')
blob_suffix = '/'.join(file.split('/')[3:])
blob_name = f'{tgt_base_dir}/{blob_suffix}'

blob = bucket.blob(blob_name)
blob.upload_from_filename(file)

Below is the code I tried:

for x in blobs:
 replace("\\", "/")
0

There are 0 best solutions below