Skip to content

Commit 20660ad

Browse files
author
SATYAM TRIPATHI
authored
Add files via upload
1 parent f81e3a4 commit 20660ad

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Import following modules
2+
import urllib.request
3+
import pandas as pd # pip install pandas
4+
from pushbullet import PushBullet # pip install pushbullet.py == 0.9.1
5+
6+
# Note: pip install openpyxl - Install this module
7+
8+
# Get Access Token from pushbullet.com
9+
Access_token = "o.aUTXEomlNPUbJQpdzl4YxQjybOSE0uRz"
10+
pb = PushBullet(Access_token) # Authentication
11+
12+
all_pushes = pb.get_pushes() # All pushes created by you
13+
latest_one = all_pushes[0] # Get the latest push
14+
url = latest_one['file_url'] # Fetch the latest file URL link
15+
16+
Text_file = "All_Chats.txt" # Create a new text file for storing all the chats
17+
# Retrieve all the data store into Text file
18+
urllib.request.urlretrieve(url, Text_file)
19+
20+
chat_list = [] # Create an empty chat list
21+
22+
# Open the Text file in read mode and read all the data
23+
with open(Text_file, mode='r', encoding='utf8') as f:
24+
data = f.readlines() # Read all the data line-by-line
25+
26+
# Excluded the first item of the list, coz first items contains some garbage data
27+
final_data_set = data[1:]
28+
29+
# Run a loop and read all the data line-by-line
30+
for line in final_data_set:
31+
date = line.split(",")[0] # Extract the date
32+
tim = line.split("-")[0].split(",")[1] # Extract the time
33+
name = line.split(":")[1].split("-")[1] # Extract the name
34+
messag = line.split(":")[2][:-1] # Extract the message
35+
# Append all the data in a List
36+
chat_list.append([date, tim, name, messag])
37+
38+
# Create a dataframe, for storing all the data in a excel file
39+
df = pd.DataFrame(chat_list, columns=['Date', 'Time', 'Name', 'Message'])
40+
df.to_excel("BackUp.xlsx", index=False)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pip install pandas
2+
pip install openpyxl
3+
pip install pushbullet.py == 0.9.1

0 commit comments

Comments
 (0)