pythonjsonpandastoadfile-encodings

pandas read_json returns ValueError: Expected object or value


Using pandas:1.4.2, I have file.json file with content as list

[
  {
    "col1":"v1",
    "col2":"v2"
  },
  ...
  {
    "col1":"v3",
    "col2":"v4"
  }
]

Read file as

pd.read_json('file.json', orient='records')

Gives ValueError: Expected object or value

I produced the file using Toad export wizard with default settings.


Solution

  • Toad default exports json as UTF-8 Unicode (with BOM)

    There should be no BOM in json 4990095.

    To resolve re-save file as UTF-8, and next time using Toad check 'no BOM' option.