Managing ChatGPT's Chat Logs
Throughout this blog I share some of the conversations I have with ChatGPT, but I'd gotten out of the routine and amassed a long list of conversations - this list was also difficult to make a copy of. In addition to this, ChatGPT was providing no up-front "date of conversation" information; two things that were hindering my desire to get back on track.
ChatGPT informed me "You can view exact timestamps if you export your ChatGPT data..." so:
Step 1: Export your ChatGPT chat data:
- Go to Settings → Data controls
- Choose Export data
You’ll get a ZIP file by email [the link to download arrived within a few minutes in my case, the file contains everything, including created and shared images, so it can be pretty large].
Inside it ... [you will find] the file:
conversations.json [mine was 20MB, spanning some 700~ conversations...]
Each conversation includes fields such as... UNIX timestamps [which] can be converted into exact human-readable dates.
Step 2: Extract the list of conversations with [human-readable] dates:
[Using Linux... and this is the neat part]
ChatGPT created this Python script for me:
import json
import csv
from datetime import datetime
input_file = "conversations.json"
output_file = "conversation_list.csv"
def convert(ts):
try:
return datetime.fromtimestamp(ts).strftime("%Y-%m-%d %H:%M:%S")
except:
return "Unknown"
with open(input_file, "r", encoding="utf-8") as f:
data = json.load(f)
with open(output_file, "w", newline="", encoding="utf-8") as out:
writer = csv.writer(out)
writer.writerow(["Title", "Created"])
for convo in data:
title = convo.get("title", "Untitled")
ts = convo.get("create_time")
readable = convert(ts) if ts else "Unknown"
writer.writerow([title, readable])
print("Done! CSV saved to", output_file)
Put that script in a file called: export_chats.py
Put that file with in the same location as the downloaded and unzipped conversations.json file
Right-click within the folder and choose: Open Terminal Here
Then use this command: python3 export_chats.py
You will now have conversation_list.csv which you can open in LibreOffice Calc.
Final Tip:
chat.html contains the conversations in a more friendly format than the web interface.
Comments
Post a Comment