<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Access file location problem in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/access-file-location-problem/m-p/15308#M9650</link>
    <description>&lt;P&gt;Hi @Reddy Massidi semi​&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just a friendly follow-up. Did you try to follow @Werner Stinckens​&amp;nbsp;'s recommendation? do you still have issues? please let us know&lt;/P&gt;</description>
    <pubDate>Tue, 27 Dec 2022 23:30:46 GMT</pubDate>
    <dc:creator>jose_gonzalez</dc:creator>
    <dc:date>2022-12-27T23:30:46Z</dc:date>
    <item>
      <title>Access file location problem</title>
      <link>https://community.databricks.com/t5/data-engineering/access-file-location-problem/m-p/15306#M9648</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;import pandas as pd
from apiclient.discovery import build
from oauth2client.service_account import ServiceAccountCredentials
df = spark.read.json("/FileStore/tables/cert.json")
&amp;nbsp;
SCOPES = ['https://www.googleapis.com/auth/analytics.readonly']
KEY_FILE_LOCATION =  "/FileStore/tables/cert.json"
VIEW_ID = '####'
&amp;nbsp;
&amp;nbsp;
def initialize_analyticsreporting():
&amp;nbsp;
  credentials = ServiceAccountCredentials.from_json_keyfile_name(KEY_FILE_LOCATION, SCOPES)
&amp;nbsp;
  # Build the service object.
  analytics = build('analyticsreporting', 'v4', credentials=credentials)
  return analytics
&amp;nbsp;
&amp;nbsp;
def get_report(analytics):
&amp;nbsp;
  return analytics.reports().batchGet(
      body={
        'reportRequests': [
        {
          'viewId': VIEW_ID,
          'dateRanges': [{'startDate': '7daysAgo', 'endDate': 'today'}],
          'metrics': [{'expression': 'ga:sessions'}],
          'dimensions': [{'name': 'ga:country'}]
        }]
      }
  ).execute()
&amp;nbsp;
&amp;nbsp;
def print_response(response):
 
  for report in response.get('reports', []):
    columnHeader = report.get('columnHeader', {})
    dimensionHeaders = columnHeader.get('dimensions', [])
    metricHeaders = columnHeader.get('metricHeader', {}).get('metricHeaderEntries', [])
&amp;nbsp;
    for row in report.get('data', {}).get('rows', []):
      dimensions = row.get('dimensions', [])
      dateRangeValues = row.get('metrics', [])
&amp;nbsp;
      for header, dimension in zip(dimensionHeaders, dimensions):
        print(header + ': ', dimension)
&amp;nbsp;
      for i, values in enumerate(dateRangeValues):
        print('Date range:', str(i))
        for metricHeader, value in zip(metricHeaders, values.get('values')):
          print(metricHeader.get('name') + ':', value)
&amp;nbsp;
&amp;nbsp;
def main():
  analytics = initialize_analyticsreporting()
  global df_response
  df_response=[]
  response = []
  response = get_report(analytics)
  
  df_response=pd.DataFrame(list(response))
&amp;nbsp;
if __name__ == '__main__':
  main()
df_response&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;im getting an error if want to acces the file location where I stored my credantiel&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;error:&lt;/P&gt;&lt;P&gt;(1) Spark Jobs&lt;/P&gt;&lt;P&gt;FileNotFoundError: [Errno 2] No such file or directory: '/FileStore/tables/cert.json'&lt;/P&gt;&lt;P&gt;but I can open my file alone without any issue:&lt;/P&gt;&lt;P&gt;df = spark.read.json("/FileStore/tables/cert.json")&lt;/P&gt;&lt;P&gt;display(df)&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2022 19:06:52 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/access-file-location-problem/m-p/15306#M9648</guid>
      <dc:creator>semi</dc:creator>
      <dc:date>2022-12-21T19:06:52Z</dc:date>
    </item>
    <item>
      <title>Re: Access file location problem</title>
      <link>https://community.databricks.com/t5/data-engineering/access-file-location-problem/m-p/15307#M9649</link>
      <description>&lt;P&gt;Looks like it is because the  oauth2client.service_account does not know about DBFS (whereas spark does).&lt;/P&gt;&lt;P&gt;Is it an option to manage your secrets in databricks? &lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.databricks.com/security/secrets/secrets.html" target="test_blank"&gt;https://docs.databricks.com/security/secrets/secrets.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Dec 2022 13:36:07 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/access-file-location-problem/m-p/15307#M9649</guid>
      <dc:creator>-werners-</dc:creator>
      <dc:date>2022-12-22T13:36:07Z</dc:date>
    </item>
    <item>
      <title>Re: Access file location problem</title>
      <link>https://community.databricks.com/t5/data-engineering/access-file-location-problem/m-p/15308#M9650</link>
      <description>&lt;P&gt;Hi @Reddy Massidi semi​&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just a friendly follow-up. Did you try to follow @Werner Stinckens​&amp;nbsp;'s recommendation? do you still have issues? please let us know&lt;/P&gt;</description>
      <pubDate>Tue, 27 Dec 2022 23:30:46 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/access-file-location-problem/m-p/15308#M9650</guid>
      <dc:creator>jose_gonzalez</dc:creator>
      <dc:date>2022-12-27T23:30:46Z</dc:date>
    </item>
    <item>
      <title>Re: Access file location problem</title>
      <link>https://community.databricks.com/t5/data-engineering/access-file-location-problem/m-p/15309#M9651</link>
      <description>&lt;P&gt;Thank you you are right the function : ServiceAccountCredentials.from_json_keyfile_name doesn't know DBFS and  I'm using a databricks community also I did assign a key in a variable call &amp;nbsp;key_variable  and pass it into this function :&lt;/P&gt;&lt;P&gt;ServiceAccountCredentials.from_json_keyfile_dict(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;key_variable, SCOPES)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;&lt;U&gt;I know it's disallowed to assign the key in a function&lt;/U&gt;&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jan 2023 16:07:07 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/access-file-location-problem/m-p/15309#M9651</guid>
      <dc:creator>semi</dc:creator>
      <dc:date>2023-01-03T16:07:07Z</dc:date>
    </item>
  </channel>
</rss>

