0

I have CSV file with column names and values in json like format. I would like to extract that column names and values to pandas.

I tried to use regexp but I cant find good code to extract what I want.

One cell on my data:

[{u'name': u'svSum7Days', u'value': 0.0}, {u'name': u'svSum91Days', u'value': 44.0}, {u'name': u'svSum364Days', u'value': 121.0}, {u'name': u'newPositionsCount60Days', u'value': 0}, {u'name': u'currentBalance', u'value': 2915.0}]

After the 'name': is column name and after that is value. I have hundreds of cells where all the columns are the same.

I would like to extract to Pandas dataframe those column names and input values from all cells to them. Could you help me with that, please?

bharatk
  • 4,202
  • 5
  • 16
  • 30

1 Answers1

1
use json
db = json.load(open('/path/to/json/file'))
len(db)

Check

Out db size as an integer

db[0].keys()

Check
Out dict_keys[.....]

M__
  • 614
  • 2
  • 10
  • 25