0

i have string name Path:

Path = 's3://ihsm-dl-automotive-dev/auto_target_marketing_data/Testing-sandbox/PP_PROCESS_TESTING_DEEPAK/Buick_Encore_studyfile'

i want to create two string and store in two different variables as given below;

bucket = 'ihsm-dl-automotive-dev'
path_new = 'auto_target_marketing_data/Testing-sandbox/PP_PROCESS_TESTING_DEEPAK/Buick_Encore_studyfile'

i have tried few option like split by delimiter like Path.split('/') but it gives me in list form.

can anyone help me with this?

  • find '//' first to get the start offset of bucket, then find the first '/' to get the end offset of bucket, which is also the start offset of the rest – Gang YIN Sep 21 '20 at 08:24

1 Answers1

0

If you already have a constant bucket name, why not split with that name and use that to split and then slice the string with :

Path.split(bucket)[1][1:]

OR

If you dont have a constant bucket string, use:

a=Path.split("/")
bucket,path=a[2],"/".join(a[3:])

This will give you a list, but you can join them using join

Yash
  • 1,271
  • 1
  • 7
  • 9