<?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: How to read JSON files embedded in a list of lists? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-read-json-files-embedded-in-a-list-of-lists/m-p/22089#M15097</link>
    <description>&lt;P&gt;For now I red the file as a Text and it gives :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="image"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/1167i0118B66030E01702/image-size/large?v=v2&amp;amp;px=999" role="button" title="image" alt="image" /&gt;&lt;/span&gt;it is the concatenation of multiple JSON files, that why the native JSON parser can't load the data. &lt;/P&gt;&lt;P&gt;The surprising thing is that it detects the right schema!&lt;/P&gt;</description>
    <pubDate>Mon, 21 Nov 2022 13:06:09 GMT</pubDate>
    <dc:creator>AmineHY</dc:creator>
    <dc:date>2022-11-21T13:06:09Z</dc:date>
    <item>
      <title>How to read JSON files embedded in a list of lists?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-read-json-files-embedded-in-a-list-of-lists/m-p/22084#M15092</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;I am trying to read this JSON file but didn't succeed &lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="image"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/1168iFC7113C6ED8D28DB/image-size/large?v=v2&amp;amp;px=999" role="button" title="image" alt="image" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="image"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/1175i538843FE31900D44/image-size/large?v=v2&amp;amp;px=999" role="button" title="image" alt="image" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can see the head of the file, JSON inside a list of lists. Any idea how to read this file?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="image"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/1178i1F260BED3E2172CB/image-size/large?v=v2&amp;amp;px=999" role="button" title="image" alt="image" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2022 13:24:01 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-read-json-files-embedded-in-a-list-of-lists/m-p/22084#M15092</guid>
      <dc:creator>AmineHY</dc:creator>
      <dc:date>2022-11-16T13:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to read JSON files embedded in a list of lists?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-read-json-files-embedded-in-a-list-of-lists/m-p/22088#M15096</link>
      <description>&lt;P&gt;Thank you for sharing,&lt;/P&gt;&lt;P&gt;these links do not address the exact problem I am facing&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2022 13:04:09 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-read-json-files-embedded-in-a-list-of-lists/m-p/22088#M15096</guid>
      <dc:creator>AmineHY</dc:creator>
      <dc:date>2022-11-21T13:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to read JSON files embedded in a list of lists?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-read-json-files-embedded-in-a-list-of-lists/m-p/22089#M15097</link>
      <description>&lt;P&gt;For now I red the file as a Text and it gives :&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="image"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/1167i0118B66030E01702/image-size/large?v=v2&amp;amp;px=999" role="button" title="image" alt="image" /&gt;&lt;/span&gt;it is the concatenation of multiple JSON files, that why the native JSON parser can't load the data. &lt;/P&gt;&lt;P&gt;The surprising thing is that it detects the right schema!&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2022 13:06:09 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-read-json-files-embedded-in-a-list-of-lists/m-p/22089#M15097</guid>
      <dc:creator>AmineHY</dc:creator>
      <dc:date>2022-11-21T13:06:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to read JSON files embedded in a list of lists?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-read-json-files-embedded-in-a-list-of-lists/m-p/22090#M15098</link>
      <description>&lt;P&gt;Here is my solution, I am sure it can be optimized&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;import json
&amp;nbsp;data=[]
with open(path_to_json_file, 'r') as f:
&amp;nbsp;  data.extend(json.load(f))
&amp;nbsp;  df = spark.createDataFrame(data[0], schema=schema)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":victory_hand:"&gt;✌️&lt;/span&gt; &lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2022 13:51:12 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-read-json-files-embedded-in-a-list-of-lists/m-p/22090#M15098</guid>
      <dc:creator>AmineHY</dc:creator>
      <dc:date>2022-11-21T13:51:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to read JSON files embedded in a list of lists?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-read-json-files-embedded-in-a-list-of-lists/m-p/22085#M15093</link>
      <description>&lt;P&gt;Hi @Amine HADJ-YOUCEF​&amp;nbsp;, The data sources are limited, please refer: &lt;A href="https://spark.apache.org/docs/latest/sql-data-sources-json.html#data-source-option" alt="https://spark.apache.org/docs/latest/sql-data-sources-json.html#data-source-option" target="_blank"&gt;https://spark.apache.org/docs/latest/sql-data-sources-json.html#data-source-option&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Also, &lt;A href="https://docs.databricks.com/external-data/json.html" alt="https://docs.databricks.com/external-data/json.html" target="_blank"&gt;https://docs.databricks.com/external-data/json.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Please let us know if this helps. &lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2022 07:31:38 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-read-json-files-embedded-in-a-list-of-lists/m-p/22085#M15093</guid>
      <dc:creator>Debayan</dc:creator>
      <dc:date>2022-11-18T07:31:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to read JSON files embedded in a list of lists?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-read-json-files-embedded-in-a-list-of-lists/m-p/89713#M37890</link>
      <description>&lt;P&gt;The correct way to do this without using open, which will work only with local/mounted files is to read the files as binaryfile and then you will get the entire json string on each row, from there you can use from_json() and explode() to extract the objects inside your array (I assume the outer array is just wrapping the other array, if you have records inside an array of arrays, then you would use explode() twice.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2024 05:33:50 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-read-json-files-embedded-in-a-list-of-lists/m-p/89713#M37890</guid>
      <dc:creator>adriennn</dc:creator>
      <dc:date>2024-09-13T05:33:50Z</dc:date>
    </item>
  </channel>
</rss>

