Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Using pushbullet to export whatsapp chat

# Import following modules
import urllib.request
import pandas as pd 
from pushbullet import PushBullet 
 
# Get Access Token from pushbullet.com
Access_token = "Your Access Token"
 
# Authentication
pb = PushBullet(Access_token) 
 
# All pushes created by you
all_pushes = pb.get_pushes() 
 
# Get the latest push
latest_one = all_pushes[0] 
 
# Fetch the latest file URL link
url = latest_one['file_url'] 
 
 
# Create a new text file for storing
# all the chats
Text_file = "All_Chats.txt" 
 
# Retrieve all the data store into
# Text file
urllib.request.urlretrieve(url, Text_file)
 
# Create an empty chat list
chat_list = [] 
 
# Open the Text file in read mode and
# read all the data
with open(Text_file, mode='r', encoding='utf8') as f:
   
     # Read all the data line-by-line
    data = f.readlines() 
 
# Excluded the first item of the list
# first items contains some garbage
# data
final_data_set = data[1:]
 
# Run a loop and read all the data
# line-by-line
for line in final_data_set:
      # Extract the date, time, name,
    # message
    date = line.split(",")[0] 
    tim = line.split("-")[0].split(",")[1] 
    name = line.split(":")[1].split("-")[1] 
    message = line.split(":")[2][:-1] 
     
    # Append all the data in a List
    chat_list.append([date, tim, name, message])
 
# Create a dataframe, for storing
# all the data in a excel file
df = pd.DataFrame(chat_list,
                  columns = ['Date', 'Time',
                             'Name', 'Message'])
df.to_excel("BackUp.xlsx", index = False)
Comment

PREVIOUS NEXT
Code Example
Python :: move a file in python 
Python :: How to Add Elements to a dictionary using the update() method 
Python :: Comparing Sets with isdisjoint() Function in python 
Python :: flask env variable 
Python :: python get the X charecters at the end of a string 
Python :: How to sort a list by even or odd numbers using a filter? 
Python :: Unable to locate package python-obexftp 
Python :: Location of INSTALLED_APP and MIDDLEWARE 
Python :: How to join or combine multiple csv files with concatenate and export dataframe to csv format 
Python :: python yield async awiat 
Python :: from django.urls import path, re_path 
Python :: python variable and data structure 
Python :: django url wildcard 
Python :: NAME.append (Line.split(",")[1].rstrip()) IndexError: list index out of range 
Python :: multiplying float variables python and print 
Python :: Power Without BuiltIn Function 
Python :: python set xticks to int not float 
Python :: python first letter to capitalize 
Python :: Source Code: Check Armstrong number (for 3 digits) 
Python :: django queryset or operator 
Python :: python networkmanager tutorial 
Python :: how to save all countries from a list in a database python 
Python :: how to create a scoreboard for the top 5 players in python 
Python :: gym for creating simple grid world 
Python :: pycharm shortcut to create methos 
Python :: alpaca examples 
Python :: Desviacion estandard en pandas 
Python :: Python Reloading a module 
Python :: osmapi 
Python :: How to provide type hinting in UserDict 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =