0

can we variablize as below if not how do we do it enter image description here

malcolm richard
  • 55
  • 3
  • 11
  • It's not recommended to use images when asking the questions - it's much easier to put text, and remove sensitive parts from it. – Alex Ott Jul 08 '20 at 15:08
  • @malcolmrichard, If my answer is helpful for you, you can accept it as answer( click on the check mark beside the answer to toggle it from greyed out to filled in.). This can be beneficial to other community members. Thank you. – CHEEKATLAPRADEEP Jul 15 '20 at 09:14

2 Answers2

0

as I see that should be the python, then just use: .load("..../{}".format(filename)). If it's Scala, then you can use .load(s".../$filename") to substitute file name...

Alex Ott
  • 80,552
  • 8
  • 87
  • 132
0

You may checkout the steps to configure the variables filename while loading the mount file name:

Step1: Declaring the variables:

mountname = 'test'
csvname = 'original.csv'
path = "dbfs:/mnt/{0}/{1}".format(mountname,csvname)

Step2: Mounting the storage account

dbutils.fs.mount(
  source = "wasbs://test@chepra.blob.core.windows.net/",
  mount_point = "/mnt/{0}".format(mountname),
  extra_configs = {"fs.azure.sas.test.chepra.blob.core.windows.net":"gv7nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXlOiA=="})
print("=> Succeeded") 

Step3: Creating the Spark Dataframe

df = spark.read.format("csv").option("sep", ",").options(header= "true", inferschema='true').option('escape','"').load("{0}".format(path))

enter image description here

CHEEKATLAPRADEEP
  • 12,191
  • 1
  • 19
  • 42