jupyter-naas / awesome-notebooks

A powerful data & AI notebook templates catalog: prompts, plugins, models, workflow automation, analytics, code snippets - following the IMO framework to be searchable and reusable in any context.
https://naas.ai/search
BSD 3-Clause "New" or "Revised" License
2.69k stars 453 forks source link

Whatsapp - Get Chat logs #1346

Closed FlorentLvr closed 1 year ago

FlorentLvr commented 1 year ago

Extract chat log from WhatsApp and return a dataframe with columns:

Here is a script to kick start the template from chatGPT:

import os
import re
import json

# Replace '/path/to/WhatsApp/ChatStorage.sqlite' with the path to your ChatStorage.sqlite file
path_to_db = '/path/to/WhatsApp/ChatStorage.sqlite'

# Connect to the database
conn = sqlite3.connect(path_to_db)
cursor = conn.cursor()

# Extract the messages from the 'messages' table in the database
cursor.execute('SELECT * FROM messages')
all_rows = cursor.fetchall()

# Extract the text and sender for each message
messages = []
for row in all_rows:
    message_text = row[4]
    sender = row[2]
    messages.append((sender, message_text))

# Print the messages
for message in messages:
    print(f'{message[0]}: {message[1]}')

# Close the connection to the database
conn.close()

This script will extract all the messages from the 'messages' table in the ChatStorage.sqlite file and print them to the console.

Please note that you will need to install the sqlite3 module and replace '/path/to/WhatsApp/ChatStorage.sqlite' with the actual path to your ChatStorage.sqlite file in order for this script to work.

FlorentLvr commented 1 year ago

@muhtalhakhan, here is the new issue! Let me know if you can get directly with python. If not, we will create a procedure to explain how to manually extract data from WhatsApp and work this export in our script. Sounds good for you?

muhtalhakhan commented 1 year ago

Hey, I am doing the same like getting the basic script from ChatGPT 😃

muhtalhakhan commented 1 year ago

First, I want to try it with python if I get failed over it then we can get it done through explanation 🤓

muhtalhakhan commented 1 year ago

Hey @FlorentLvr I have tried exporting chats cause I need to find out the Chatstorage.sqlite file but the file I am getting is in text format.

What to do now?

While I have setup the code to extract the messages along with date and time but- through text I am getting "Date, Time and Username with text".

Example: 12/25/22, 02:16 - Muhammad Talha Khan: Shittt

FlorentLvr commented 1 year ago

Hey @FlorentLvr I have tried exporting chats cause I need to find out the Chatstorage.sqlite file but the file I am getting is in text format.

What to do now?

While I have setup the code to extract the messages along with date and time but- through text I am getting "Date, Time and Username with text".

Example: 12/25/22, 02:16 - Muhammad Talha Khan: Shittt

If I sum it up:

Even if everything is not automated yet, I would be super valuable to have the process to extract your chatlog from WhatsApp :) 🙏

muhtalhakhan commented 1 year ago

Alright, I am trying to get it done through txt file as I have already exported my chat data.

muhtalhakhan commented 1 year ago

Hey @FlorentLvr

Please see:

You can use a tool called "WhatsApp Viewer" to export WhatsApp chat logs as a SQLite database file. Here's how:

Download and install WhatsApp Viewer from the following link: https://www.flamingtool.com/whatsappviewer

Run WhatsApp Viewer and click on the "Select WhatsApp backup file" button.

Navigate to the folder where your WhatsApp backup file is stored and select it. The default location for WhatsApp backup files is: "C:\Users[Your User Name]\AppData\Roaming\WhatsApp\Databases"

Once the backup file has been selected, click on the "Export" button.

In the "Export" window, select "SQLite database" as the export format and click on the "Export" button.

Choose a destination folder for the exported database file and click on the "Save" button.

That's it! You should now have a SQLite database file containing your WhatsApp chat logs. You can use a SQLite viewer tool to view and query the contents of the database.

I be using this to get the database exported or can use split function for the text file to be read.

FlorentLvr commented 1 year ago

Hey @FlorentLvr

Please see:

You can use a tool called "WhatsApp Viewer" to export WhatsApp chat logs as a SQLite database file. Here's how: Download and install WhatsApp Viewer from the following link: https://www.flamingtool.com/whatsappviewer Run WhatsApp Viewer and click on the "Select WhatsApp backup file" button. Navigate to the folder where your WhatsApp backup file is stored and select it. The default location for WhatsApp backup files is: "C:\Users[Your User Name]\AppData\Roaming\WhatsApp\Databases" Once the backup file has been selected, click on the "Export" button. In the "Export" window, select "SQLite database" as the export format and click on the "Export" button. Choose a destination folder for the exported database file and click on the "Save" button. That's it! You should now have a SQLite database file containing your WhatsApp chat logs. You can use a SQLite viewer tool to view and query the contents of the database.

I be using this to get the database exported or can use split function for the text file to be read.

Hi @muhtalhakhan!

TY for your feebacks! Unfortunately, I can not access the "flamingtool.com". Are you sure it's the right link? Can you create a template and read the file using this code ?

import sqlite3

def read_from_db(db_file):
    con = sqlite3.connect(db_file)
    cur = con.cursor()

    cur.execute("SELECT * FROM tablename")
    rows = cur.fetchall()

    for row in rows:
        print(row)
    con.close()
muhtalhakhan commented 1 year ago

Hey @FlorentLvr

I've tried exporting and sliced it and working to make it a SQLite DB file but- Today I couldn't find enough time.

I be needing some help from you, is there any way to reach out you directly and swiftly?

Thank you!

On Tue, Jan 10, 2023, 13:24 FlorentLvr @.***> wrote:

Hey @FlorentLvr https://github.com/FlorentLvr

Please see:

You can use a tool called "WhatsApp Viewer" to export WhatsApp chat logs as a SQLite database file. Here's how: Download and install WhatsApp Viewer from the following link: https://www.flamingtool.com/whatsappviewer Run WhatsApp Viewer and click on the "Select WhatsApp backup file" button. Navigate to the folder where your WhatsApp backup file is stored and select it. The default location for WhatsApp backup files is: "C:\Users[Your User Name]\AppData\Roaming\WhatsApp\Databases" Once the backup file has been selected, click on the "Export" button. In the "Export" window, select "SQLite database" as the export format and click on the "Export" button. Choose a destination folder for the exported database file and click on the "Save" button. That's it! You should now have a SQLite database file containing your WhatsApp chat logs. You can use a SQLite viewer tool to view and query the contents of the database.

I be using this to get the database exported or can use split function for the text file to be read.

Hi @muhtalhakhan https://github.com/muhtalhakhan!

TY for your feebacks! Unfortunately, I can not access the "flamingtool.com". Are you sure it's the right link? Can you create a template and read the file using this code ?

import sqlite3

def read_from_db(db_file): con = sqlite3.connect(db_file) cur = con.cursor()

cur.execute("SELECT * FROM tablename")
rows = cur.fetchall()

for row in rows:
    print(row)
con.close()

— Reply to this email directly, view it on GitHub https://github.com/jupyter-naas/awesome-notebooks/issues/1346#issuecomment-1376891792, or unsubscribe https://github.com/notifications/unsubscribe-auth/APA3FDHIPFSAW6T7IBMECUTWRUMDZANCNFSM6AAAAAATVQMJNI . You are receiving this because you were mentioned.Message ID: @.***>

FlorentLvr commented 1 year ago

Hey @FlorentLvr I've tried exporting and sliced it and working to make it a SQLite DB file but- Today I couldn't find enough time. I be needing some help from you, is there any way to reach out you directly and swiftly? Thank you! On Tue, Jan 10, 2023, 13:24 FlorentLvr @.> wrote: Hey @FlorentLvr https://github.com/FlorentLvr Please see: You can use a tool called "WhatsApp Viewer" to export WhatsApp chat logs as a SQLite database file. Here's how: Download and install WhatsApp Viewer from the following link: https://www.flamingtool.com/whatsappviewer Run WhatsApp Viewer and click on the "Select WhatsApp backup file" button. Navigate to the folder where your WhatsApp backup file is stored and select it. The default location for WhatsApp backup files is: "C:\Users[Your User Name]\AppData\Roaming\WhatsApp\Databases" Once the backup file has been selected, click on the "Export" button. In the "Export" window, select "SQLite database" as the export format and click on the "Export" button. Choose a destination folder for the exported database file and click on the "Save" button. That's it! You should now have a SQLite database file containing your WhatsApp chat logs. You can use a SQLite viewer tool to view and query the contents of the database. I be using this to get the database exported or can use split function for the text file to be read. Hi @muhtalhakhan https://github.com/muhtalhakhan! TY for your feebacks! Unfortunately, I can not access the "flamingtool.com". Are you sure it's the right link? Can you create a template and read the file using this code ? import sqlite3 def read_from_db(db_file): con = sqlite3.connect(db_file) cur = con.cursor() cur.execute("SELECT FROM tablename") rows = cur.fetchall() for row in rows: print(row) con.close() — Reply to this email directly, view it on GitHub <#1346 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/APA3FDHIPFSAW6T7IBMECUTWRUMDZANCNFSM6AAAAAATVQMJNI . You are receiving this because you were mentioned.Message ID: **@.***>

@muhtalhakhan, you can reach me on Slack

muhtalhakhan commented 1 year ago

Alright, @FlorentLvr I'll get you today and discuss about it. Let's finish it off Saturday.

On Wed, Jan 11, 2023, 13:20 FlorentLvr @.***> wrote:

Hey @FlorentLvr https://github.com/FlorentLvr I've tried exporting and sliced it and working to make it a SQLite DB file but- Today I couldn't find enough time. I be needing some help from you, is there any way to reach out you directly and swiftly? Thank you! … <#m_550459548627585568m-697253169884956902_> On Tue, Jan 10, 2023, 13:24 FlorentLvr @.> wrote: Hey @FlorentLvr https://github.com/FlorentLvr https://github.com/FlorentLvr https://github.com/FlorentLvr Please see: You can use a tool called "WhatsApp Viewer" to export WhatsApp chat logs as a SQLite database file. Here's how: Download and install WhatsApp Viewer from the following link: https://www.flamingtool.com/whatsappviewer https://www.flamingtool.com/whatsappviewer Run WhatsApp Viewer and click on the "Select WhatsApp backup file" button. Navigate to the folder where your WhatsApp backup file is stored and select it. The default location for WhatsApp backup files is: "C:\Users[Your User Name]\AppData\Roaming\WhatsApp\Databases" Once the backup file has been selected, click on the "Export" button. In the "Export" window, select "SQLite database" as the export format and click on the "Export" button. Choose a destination folder for the exported database file and click on the "Save" button. That's it! You should now have a SQLite database file containing your WhatsApp chat logs. You can use a SQLite viewer tool to view and query the contents of the database. I be using this to get the database exported or can use split function for the text file to be read. Hi @muhtalhakhan https://github.com/muhtalhakhan https://github.com/muhtalhakhan https://github.com/muhtalhakhan! TY for your feebacks! Unfortunately, I can not access the "flamingtool.com http://flamingtool.com". Are you sure it's the right link? Can you create a template and read the file using this code ? import sqlite3 def read_from_db(db_file): con = sqlite3.connect(db_file) cur = con.cursor() cur.execute("SELECT FROM tablename") rows = cur.fetchall() for row in rows: print(row) con.close() — Reply to this email directly, view it on GitHub <#1346 (comment) https://github.com/jupyter-naas/awesome-notebooks/issues/1346#issuecomment-1376891792>, or unsubscribe https://github.com/notifications/unsubscribe-auth/APA3FDHIPFSAW6T7IBMECUTWRUMDZANCNFSM6AAAAAATVQMJNI https://github.com/notifications/unsubscribe-auth/APA3FDHIPFSAW6T7IBMECUTWRUMDZANCNFSM6AAAAAATVQMJNI . You are receiving this because you were mentioned.Message ID: @.*>

@muhtalhakhan https://github.com/muhtalhakhan, you can reach me on Slack

— Reply to this email directly, view it on GitHub https://github.com/jupyter-naas/awesome-notebooks/issues/1346#issuecomment-1378385804, or unsubscribe https://github.com/notifications/unsubscribe-auth/APA3FDCR7B4HF7DPVNZYCQDWRZUMTANCNFSM6AAAAAATVQMJNI . You are receiving this because you were mentioned.Message ID: @.***>

muhtalhakhan commented 1 year ago

Talking about the heatmap template related to Whatsapp.

On Thu, Jan 12, 2023, 02:56 Muhammad Talha Khan @.***> wrote:

Alright, @FlorentLvr I'll get you today and discuss about it. Let's finish it off Saturday.

On Wed, Jan 11, 2023, 13:20 FlorentLvr @.***> wrote:

Hey @FlorentLvr https://github.com/FlorentLvr I've tried exporting and sliced it and working to make it a SQLite DB file but- Today I couldn't find enough time. I be needing some help from you, is there any way to reach out you directly and swiftly? Thank you! … <#m_4513294337528107497_m_550459548627585568m-697253169884956902_> On Tue, Jan 10, 2023, 13:24 FlorentLvr @.> wrote: Hey @FlorentLvr https://github.com/FlorentLvr https://github.com/FlorentLvr https://github.com/FlorentLvr Please see: You can use a tool called "WhatsApp Viewer" to export WhatsApp chat logs as a SQLite database file. Here's how: Download and install WhatsApp Viewer from the following link: https://www.flamingtool.com/whatsappviewer https://www.flamingtool.com/whatsappviewer Run WhatsApp Viewer and click on the "Select WhatsApp backup file" button. Navigate to the folder where your WhatsApp backup file is stored and select it. The default location for WhatsApp backup files is: "C:\Users[Your User Name]\AppData\Roaming\WhatsApp\Databases" Once the backup file has been selected, click on the "Export" button. In the "Export" window, select "SQLite database" as the export format and click on the "Export" button. Choose a destination folder for the exported database file and click on the "Save" button. That's it! You should now have a SQLite database file containing your WhatsApp chat logs. You can use a SQLite viewer tool to view and query the contents of the database. I be using this to get the database exported or can use split function for the text file to be read. Hi @muhtalhakhan https://github.com/muhtalhakhan https://github.com/muhtalhakhan https://github.com/muhtalhakhan! TY for your feebacks! Unfortunately, I can not access the "flamingtool.com http://flamingtool.com". Are you sure it's the right link? Can you create a template and read the file using this code ? import sqlite3 def read_from_db(db_file): con = sqlite3.connect(db_file) cur = con.cursor() cur.execute("SELECT FROM tablename") rows = cur.fetchall() for row in rows: print(row) con.close() — Reply to this email directly, view it on GitHub <#1346 (comment) https://github.com/jupyter-naas/awesome-notebooks/issues/1346#issuecomment-1376891792>, or unsubscribe https://github.com/notifications/unsubscribe-auth/APA3FDHIPFSAW6T7IBMECUTWRUMDZANCNFSM6AAAAAATVQMJNI https://github.com/notifications/unsubscribe-auth/APA3FDHIPFSAW6T7IBMECUTWRUMDZANCNFSM6AAAAAATVQMJNI . You are receiving this because you were mentioned.Message ID: @.*>

@muhtalhakhan https://github.com/muhtalhakhan, you can reach me on Slack

— Reply to this email directly, view it on GitHub https://github.com/jupyter-naas/awesome-notebooks/issues/1346#issuecomment-1378385804, or unsubscribe https://github.com/notifications/unsubscribe-auth/APA3FDCR7B4HF7DPVNZYCQDWRZUMTANCNFSM6AAAAAATVQMJNI . You are receiving this because you were mentioned.Message ID: @.***>

muhtalhakhan commented 1 year ago

@FlorentLvr please check your Slack

jravenel commented 1 year ago

Putting it back to Backlog