<?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 Using F Strings in filenames to read in files from mounted containers in Get Started Discussions</title>
    <link>https://community.databricks.com/t5/get-started-discussions/using-f-strings-in-filenames-to-read-in-files-from-mounted/m-p/36171#M273</link>
    <description>&lt;P&gt;Below are 2 versions of codes I tried and the failure messages. Does anyone have advice how to form this properly?&lt;/P&gt;&lt;P&gt;I tried this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;for x in range(2,num_organization_page,1):
file_str = f"dbfs:/mnt/dlsi2023/raw/ds_pet_finder_organization{x}.json",
print(file_str)
organizations_df = spark.read.option("multiline","true").json(f"{file_str}")
&lt;/LI-CODE&gt;&lt;P&gt;and got this error:&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;('dbfs:/mnt/dlsi2023/raw/ds_pet_finder_organization2.json',)&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;IllegalArgumentException: java.net.URISyntaxException: Illegal character in scheme name at index 0: ('dbfs:/mnt/dlsi2023/raw/ds_pet_finder_organization2.json',)&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;I tried this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;for x in range(2,num_organization_page,1):
file_str = f"/mnt/dlsi2023/raw/ds_pet_finder_organization{x}.json",
print(file_str)
organizations_df = spark.read.option("multiline","true").json(f"{file_str}")&lt;/LI-CODE&gt;&lt;P&gt;and got this error:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;('/mnt/dlsi2023/raw/ds_pet_finder_organization2.json',)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;IllegalArgumentException: Path must be absolute: ('/mnt/dlsi2023/raw/ds_pet_finder_organization2.json',)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 29 Jun 2023 14:24:54 GMT</pubDate>
    <dc:creator>jch</dc:creator>
    <dc:date>2023-06-29T14:24:54Z</dc:date>
    <item>
      <title>Using F Strings in filenames to read in files from mounted containers</title>
      <link>https://community.databricks.com/t5/get-started-discussions/using-f-strings-in-filenames-to-read-in-files-from-mounted/m-p/36171#M273</link>
      <description>&lt;P&gt;Below are 2 versions of codes I tried and the failure messages. Does anyone have advice how to form this properly?&lt;/P&gt;&lt;P&gt;I tried this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;for x in range(2,num_organization_page,1):
file_str = f"dbfs:/mnt/dlsi2023/raw/ds_pet_finder_organization{x}.json",
print(file_str)
organizations_df = spark.read.option("multiline","true").json(f"{file_str}")
&lt;/LI-CODE&gt;&lt;P&gt;and got this error:&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;('dbfs:/mnt/dlsi2023/raw/ds_pet_finder_organization2.json',)&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;IllegalArgumentException: java.net.URISyntaxException: Illegal character in scheme name at index 0: ('dbfs:/mnt/dlsi2023/raw/ds_pet_finder_organization2.json',)&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;I tried this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;for x in range(2,num_organization_page,1):
file_str = f"/mnt/dlsi2023/raw/ds_pet_finder_organization{x}.json",
print(file_str)
organizations_df = spark.read.option("multiline","true").json(f"{file_str}")&lt;/LI-CODE&gt;&lt;P&gt;and got this error:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;('/mnt/dlsi2023/raw/ds_pet_finder_organization2.json',)&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;IllegalArgumentException: Path must be absolute: ('/mnt/dlsi2023/raw/ds_pet_finder_organization2.json',)&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jun 2023 14:24:54 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/using-f-strings-in-filenames-to-read-in-files-from-mounted/m-p/36171#M273</guid>
      <dc:creator>jch</dc:creator>
      <dc:date>2023-06-29T14:24:54Z</dc:date>
    </item>
    <item>
      <title>Re: Using F Strings in filenames to read in files from mounted containers</title>
      <link>https://community.databricks.com/t5/get-started-discussions/using-f-strings-in-filenames-to-read-in-files-from-mounted/m-p/36929#M382</link>
      <description>&lt;P&gt;Your code works, you just have to remove the comma at the end of the second line&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;file_str = f"dbfs:/mnt/dlsi2023/raw/ds_pet_finder_organization{x}.json",&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Should be&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;file_str = f"dbfs:/mnt/dlsi2023/raw/ds_pet_finder_organization{x}.json"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;This is what is causing the error.&lt;/P&gt;&lt;P&gt;Also note that&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;f"&lt;/SPAN&gt;&lt;SPAN&gt;{file_str}&lt;/SPAN&gt;&lt;SPAN&gt;" is equivalent to just&amp;nbsp;file_str : No f-string needed here !&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 04 Jul 2023 11:54:00 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/using-f-strings-in-filenames-to-read-in-files-from-mounted/m-p/36929#M382</guid>
      <dc:creator>erigaud</dc:creator>
      <dc:date>2023-07-04T11:54:00Z</dc:date>
    </item>
  </channel>
</rss>

