Export data using pandas

Sulaeman rasyid
Sep 28, 2021

Hello in this tutorial we will using pandas for import data from json to csv.

for IDE i use pycharm

for instalation

pip install pandas

Anyway, we will create application from project before:

import pandas


import pandas as pd

add new variabel

dataCollect = []

for collect data from looping

add code after title name item

item = {
'url': url,
'title': title,
'img': img
}
dataCollect.append(item)

add code after looping

print (dataCollect)

the output will like

finally we can export data using pandas

df = pd.DataFrame(dataCollect)
df.to_csv('result-kompas.csv', index=False)

full code like

--

--