Skip to content

Instantly share code, notes, and snippets.

@ZackStone
Created December 21, 2017 13:29
Show Gist options
  • Save ZackStone/8f14277cf2f896ecbfd446e582e3752e to your computer and use it in GitHub Desktop.
Save ZackStone/8f14277cf2f896ecbfd446e582e3752e to your computer and use it in GitHub Desktop.
Exportar dados do bot para planilha
# -*- coding: utf-8 -*-
"""
Created on Thu Dec 21 10:32:59 2017
@author: yitzhak.andrade
Extrair as intenções identificadas e os textos digitados pelos usuários e exportar para uma planilha.
"""
import pandas as pd
import json
FILENAME = 'chatbot-ti.json'
#%%
with open(FILENAME, encoding='utf-8') as file:
bot_json = json.load(file)
#%%
obj = pd.DataFrame.from_dict(bot_json, orient='index')
json_hist = obj.loc['utterances'][0]
#%%
df_out = pd.DataFrame.from_dict(json_hist)
writer = pd.ExcelWriter('chatbot-ti.xlsx')
df_out.to_excel(writer,'Sheet1')
writer.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment