Kuldip Joshi
Kuldip Joshi

Reputation: 47

How to convert csv to complex json

enter image description here

How to do this stuff in python pandas? I am trying to make put request to some API and not sure how to generate request body since I have the csv file only . Request body asks for fixed set of schema

Upvotes: 0

Views: 37

Answers (1)

Robert Axe
Robert Axe

Reputation: 414

Dataframe has a function to_dict.

documents = df.to_dict(orient='records')
result = {'items': documents}

Upvotes: 1

Related Questions