I have two files, for example
- Excel
ID | Price | Status |
---|---|---|
1 | 1000 | Free |
2 | 2000 | Option |
3 | 3000 | Reserved |
- JSON
{
"id": 1,
"price": "1000",
"status": "free",
}
{
"id": 2,
"localization": "2000",
"reference": "Option",
}
{
"id": 3,
"localization": "3000",
"reference": "Reserved",
}
How I should compare these files? Which commands should be useful?
CodePudding user response:
You can use pandas
for this
from pandas.testing import assert_frame_equal
df1 = pd.read_excel("your excell file path")
df2 = pd.read_json("your json file path") # or you can create using pd.DataFrame.from_dict(your_dict)
assert_frame_equal(df1, df2) # this will check if two dataframes are equal or not