title: JSON_Normalize (nested json) to csv
body: <p>I have been trying via pandas to extract data from a txt file containing json utf-8 encoded data.</p>
  <p>Direct link to data file - <a href="http://download.companieshouse.gov.uk/psc-snapshot-2022-02-06_8of20.zip" rel="nofollow noreferrer">http://download.companieshouse.gov.uk/psc-snapshot-2022-02-06_8of20.zip</a></p>
  <p>Data's structure looks like the following examples:</p>
  <pre><code>{&quot;company_number&quot;:&quot;04732933&quot;,&quot;data&quot;:{&quot;address&quot;:{&quot;address_line_1&quot;:&quot;Windsor Road&quot;,&quot;locality&quot;:&quot;Torquay&quot;,&quot;postal_code&quot;:&quot;TQ1 1ST&quot;,&quot;premises&quot;:&quot;Windsor Villas&quot;,&quot;region&quot;:&quot;Devon&quot;},&quot;country_of_residence&quot;:&quot;England&quot;,&quot;date_of_birth&quot;:{&quot;month&quot;:1,&quot;year&quot;:1964},&quot;etag&quot;:&quot;5623f35e4bb5dc9cb37e134cb2ac0ca3151cd01f&quot;,&quot;kind&quot;:&quot;individual-person-with-significant-control&quot;,&quot;links&quot;:{&quot;self&quot;:&quot;/company/04732933/persons-with-significant-control/individual/8X3LALP5gAh5dAYEOYimeiRiJMQ&quot;},&quot;name&quot;:&quot;Ms Karen Mychals&quot;,&quot;name_elements&quot;:{&quot;forename&quot;:&quot;Karen&quot;,&quot;surname&quot;:&quot;Mychals&quot;,&quot;title&quot;:&quot;Ms&quot;},&quot;nationality&quot;:&quot;British&quot;,&quot;natures_of_control&quot;:[&quot;ownership-of-shares-50-to-75-percent&quot;],&quot;notified_on&quot;:&quot;2016-04-06&quot;}}
  {&quot;company_number&quot;:&quot;10118870&quot;,&quot;data&quot;:{&quot;address&quot;:{&quot;address_line_1&quot;:&quot;Hilltop Road&quot;,&quot;address_line_2&quot;:&quot;Bearpark&quot;,&quot;country&quot;:&quot;England&quot;,&quot;locality&quot;:&quot;Durham&quot;,&quot;postal_code&quot;:&quot;DH7 7TL&quot;,&quot;premises&quot;:&quot;54&quot;},&quot;ceased_on&quot;:&quot;2019-04-15&quot;,&quot;country_of_residence&quot;:&quot;England&quot;,&quot;date_of_birth&quot;:{&quot;month&quot;:9,&quot;year&quot;:1983},&quot;etag&quot;:&quot;5b3c984156794e5519851b7f1b22d1bbd2a5c5df&quot;,&quot;kind&quot;:&quot;individual-person-with-significant-control&quot;,&quot;links&quot;:{&quot;self&quot;:&quot;/company/10118870/persons-with-significant-control/individual/hS6dYoZ234aXhmI6Q9y83QbAhSY&quot;},&quot;name&quot;:&quot;Mr Patrick John Burns&quot;,&quot;name_elements&quot;:{&quot;forename&quot;:&quot;Patrick&quot;,&quot;middle_name&quot;:&quot;John&quot;,&quot;surname&quot;:&quot;Burns&quot;,&quot;title&quot;:&quot;Mr&quot;},&quot;nationality&quot;:&quot;British&quot;,&quot;natures_of_control&quot;:[&quot;ownership-of-shares-25-to-50-percent&quot;,&quot;voting-rights-25-to-50-percent&quot;],&quot;notified_on&quot;:&quot;2017-04-06&quot;}}
  </code></pre>
  <p>The simple<code>pd.read_json</code> did not work  initially (I would get ValueError: Trailing data errors)  until <code>lines=true</code> was used (using jupyternotebook for this).</p>
  <pre><code>import pandas as pd
  import json
  df = pd.read_json(r'E:\JSON_data\psc-snapshot-2022-02-06_8of20.txt', encoding='utf8', lines=True)
  </code></pre>
  <p>this is how the data structure is displayed via <code>df.head()</code> :</p>
  <pre><code>    company_number  data
  0   06851805    {'address': {'address_line_1': 'Briar Road', '...
  1   04732933    {'address': {'address_line_1': 'Windsor Road',...
  2   10118870    {'address': {'address_line_1': 'Hilltop Road',...
  3   10118870    {'address': {'address_line_1': 'Hilltop Road',...
  4   09565353    {'address': {'address_line_1': 'Old Hertford R...
  </code></pre>
  <p>After looking through stackoverflow and several online tutorials I tried using <code>pd.json_normalize(df)</code> but keep getting a <code>AttributeError: 'str' object has no attribute 'values'</code> error. I would like to ultimately export this json file into a csv file.</p>
  <p>thank you in advance for any advice!</p>