<?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: Reading single file from Databricks DBFS in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/reading-single-file-from-databricks-dbfs/m-p/88812#M37621</link>
    <description>&lt;P&gt;From what I know, you can't acess filestore directly through python, it's something that is not supported by databricks and there is some reasons for it.&lt;BR /&gt;You should use instead the spark function as you mentioned or a db function(dbutils)&lt;/P&gt;</description>
    <pubDate>Fri, 06 Sep 2024 02:31:48 GMT</pubDate>
    <dc:creator>EricRM</dc:creator>
    <dc:date>2024-09-06T02:31:48Z</dc:date>
    <item>
      <title>Reading single file from Databricks DBFS</title>
      <link>https://community.databricks.com/t5/data-engineering/reading-single-file-from-databricks-dbfs/m-p/88810#M37620</link>
      <description>&lt;P&gt;I have a Test.csv file in &lt;EM&gt;FileStore of DBFS in &lt;STRONG&gt;Databricks Community edition. &lt;/STRONG&gt;&lt;/EM&gt;When I try to read the file using With Open, I get the following &lt;STRONG&gt;error&lt;/STRONG&gt;:&lt;EM&gt;&lt;EM&gt;&lt;SPAN class=""&gt;FileNotFoundError: [Errno 2] No such file or directory: '/dbfs/FileStore/tables/Test.csv'&lt;/SPAN&gt;&lt;/EM&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import os
with open('/dbfs/FileStore/tables/Test.csv') as testFile:
    testContent = testFile.read()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Question&lt;/STRONG&gt;: What could be a cause of the error and how can we fix it?&lt;/P&gt;&lt;P&gt;The file gets loaded successfully in a df as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;df = spark.read.csv("/FileStore/tables/Test.csv", header=True, inferSchema=True)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Sep 2024 02:22:14 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/reading-single-file-from-databricks-dbfs/m-p/88810#M37620</guid>
      <dc:creator>Saf4Databricks</dc:creator>
      <dc:date>2024-09-06T02:22:14Z</dc:date>
    </item>
    <item>
      <title>Re: Reading single file from Databricks DBFS</title>
      <link>https://community.databricks.com/t5/data-engineering/reading-single-file-from-databricks-dbfs/m-p/88812#M37621</link>
      <description>&lt;P&gt;From what I know, you can't acess filestore directly through python, it's something that is not supported by databricks and there is some reasons for it.&lt;BR /&gt;You should use instead the spark function as you mentioned or a db function(dbutils)&lt;/P&gt;</description>
      <pubDate>Fri, 06 Sep 2024 02:31:48 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/reading-single-file-from-databricks-dbfs/m-p/88812#M37621</guid>
      <dc:creator>EricRM</dc:creator>
      <dc:date>2024-09-06T02:31:48Z</dc:date>
    </item>
    <item>
      <title>Re: Reading single file from Databricks DBFS</title>
      <link>https://community.databricks.com/t5/data-engineering/reading-single-file-from-databricks-dbfs/m-p/88813#M37622</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/88916"&gt;@EricRM&lt;/a&gt;&amp;nbsp;It should work. Please see the accepted response from this same forum &lt;A title="here" href="https://community.databricks.com/t5/data-engineering/python-open-function-is-unable-to-detect-the-file-in-dbfs/td-p/28120" target="_blank" rel="noopener"&gt;here&lt;/A&gt;. So, we still need to find a cause of the error. Following is the detailed error message. Maybe, this will help readers understand the issue better and help it resolve:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;FileNotFoundError                         Traceback (most recent call last)
File &amp;lt;command-1762145911467087&amp;gt;, line 2
      1 import os
----&amp;gt; 2 with open('/dbfs/FileStore/tables/Test.csv', 'rb') as testFile:
      3     testContent = testFile.read()

File /databricks/python/lib/python3.11/site-packages/IPython/core/interactiveshell.py:286, in _modified_open(file, *args, **kwargs)
    279 if file in {0, 1, 2}:
    280     raise ValueError(
    281         f"IPython won't let you open fd={file} by default "
    282         "as it is likely to crash IPython. If you know what you are doing, "
    283         "you can use builtins' open."
    284     )
--&amp;gt; 286 return io_open(file, *args, **kwargs)

FileNotFoundError: [Errno 2] No such file or directory: '/dbfs/FileStore/tables/Test.csv'&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 06 Sep 2024 03:28:21 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/reading-single-file-from-databricks-dbfs/m-p/88813#M37622</guid>
      <dc:creator>Saf4Databricks</dc:creator>
      <dc:date>2024-09-06T03:28:21Z</dc:date>
    </item>
  </channel>
</rss>

