title: How to create df dynamically while looping list in python?
body: <pre><code>def create_df(src,header=None):
      df =spark.read.csv(src, header=header)
      return df
  
  result = source_df.filter(f.col('Job_name') == job_name).select(source_df['dfname'],source_df['srcpath']).collect()
  
  for x in result:
      src=str('"' +x[1] + '"'.strip(' '))
      src = str(src)
      x[0] = create_df(src, header=True)   //throwing an uft-8 encod
  </code></pre>
  
  <p>result is a list having 2 columns called dfname and source path, need to loop the result list and based on the dfname value need to create pass df name dynamically.</p>
  
  <pre><code>| dfname     | SPath        |
  |------------+--------------|
  | Account_Df | s3://path... |
  | ProdMet_Df | s3://path... |
  </code></pre>
  
  <p>Based on the df name need to create dfnames?</p>
  
  <p>expected output 
  Account_Df and ProdMet_Df two sepate dfs. </p>