-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmessage-processor.py
More file actions
40 lines (26 loc) · 951 Bytes
/
message-processor.py
File metadata and controls
40 lines (26 loc) · 951 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# -*- coding: utf-8 -*-
import sqlite3
conn = sqlite3.connect('messages.db')
c = conn.cursor()
# list of numbers
handlesFile = open('output/handles.txt', 'w')
for row in c.execute('SELECT id FROM handle'):
handlesFile.writelines(row[0] + '\n')
handlesFile.close()
# texts from me
meFile = open('output/me.txt', 'w')
for row in c.execute('SELECT text FROM message WHERE is_from_me=1'):
if row[0] != None:
myString = row[0] + u'\n'
meFile.write(myString.encode("utf-8"))
meFile.close()
# texts by person
allFile = open('output/all.txt', 'w')
for row in c.execute('SELECT text,handle.id,message.service,date,date_read,date_delivered,is_from_me FROM message INNER JOIN handle ON message.handle_id = handle.ROWID ORDER BY handle.ROWID,date'):
if row[0] != None:
myString = u'+++' + row[0] + u'+++,'
allFile.write(myString.encode("utf-8"))
for data in row[1:]:
allFile.write(str(data) + ',')
allFile.write('\n')
allFile.close()