2

I'm scraping resources in python and I want to make a json file, using it in Openrefine to clean data.

Here's my code:

import json
import codecs

A = xpath
B = xpath
C = xpath
D = xpath

with codecs.open('info2.json', 'a', 'utf-8-sig') as f:
    json.dump({'A': A, 'B': B, 'C': C, 'D': D}, f, sort_keys=True, indent=4, ensure_ascii=False)

It's all right until I'll upload the file in Openrefine: I can't click on the right node, but only on a specific element. Here's an example:

I can click only on a specific element

I think there's an error producing the json with python, I tryed putting two {{}} but it gives me a "dict" error, so I tryed putting elements into arrays but nothing worked.

As request, here is a part of the json:

enter image description here

p.s. I'm using codecs because there are non-latin characters

Holloway
  • 6,412
  • 1
  • 26
  • 33
Lara M.
  • 855
  • 2
  • 10
  • 23

1 Answers1

1

To make the node selectable in the OpenRefine import you need to enclose the array in a node - e.g.

{
  "DISTRIBUTION": [
    "JHU",
    "123"
  ],
  "IMMAGINE": {
    "IMMAGINELIST": [
      "1",
      "2",
      "3"
    ]
  }
}
Owen Stephens
  • 1,550
  • 1
  • 8
  • 10