When I use iteration for each cell, json_normalize gives error.
I even tried creating a dict of all cells, still the json_normalize
does not work over it.
We would need to see your code. Please provide it in a reply between
triple backticks, eg:
```
your code
goes here
```
There’s a </> button in the compose tool bar which makes such a
section.
We also need to see the entire error and so forth.
There is a long json string and I have changed it to an excel file using pandas and there is a comments column in that json which itself is a json file, I need to explode each row of that comments column
The below code works correctly as its working on a single json comments field .
import json
import pandas as pd
data1="Some large json file comments field"
df = pd.json_normalize(data1)
print(df.head())
df.to_excel(r"C:\Users\Niraj.Chaughule\Desktop\testexport1.xlsx", index=False)
But when i try to iterate it, it gives an error–
import json
import pandas as pd
import openpyxl
wb = openpyxl.load_workbook(r'C:\Users\Niraj.Chaughule\Desktop\scannedcol.xlsx')
sheet = wb.active
cell_range_values = []
for row in sheet.iter_rows(min_row=1, max_row=3, min_col=1, max_col=3):
cell_values = [cell.value for cell in row]
cell_range_values.append(cell_values)
print("Cell range A1 to C3:")
for row_values in cell_range_values:
x=print(row_values)
print (x)
normalized_data = pd.json_normalize(x)
print(normalized_data)
This above code always gives an error either unicode escape or raise not implemented error.
I have tried using json_loads, json_dumps and then passing it to json_normalize, still it results in an error.
The error is—
line 447, in json_normalize
raise NotImplementedError
NotImplementedError
or sometimes it gives unicode escape error \uxxxx or \Uxxxx.