-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathallinone2grab.py
More file actions
27 lines (19 loc) · 913 Bytes
/
Copy pathallinone2grab.py
File metadata and controls
27 lines (19 loc) · 913 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
import ezgmail # for Gmail integration "pip install ezgmail"
import csv # for CSV writing
import os # for file operations
import re # for regular expressions
# Go to directory that has GMAIL credentials.json and token.json and run init script:
os.chdir(r'C:\tmp')
ezgmail.init()
# Search GMAIL for emails from CDG Taxi and then download all attachments:
resultThreads = ezgmail.search('from:no-reply@grab.com subject:Your GRAB E-Receipt)', maxResults=300)
print('results found ' + str(len(resultThreads)))
with open (r'C:\tmp\output6.csv', 'w', newline='') as csvfile:
try:
for i in range (0, 300):
writer = csv.writer(csvfile, delimiter=',')
writer.writerow(resultThreads[(i)].messages)
print('row ' +str(i)+ ' done')
except IndexError:
pass
print('done')