Hello Le Wagon 👋
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- data for 1 day: 479 MB scanned | |
| SELECT * | |
| FROM `bigquery-public-data.google_trends.international_top_terms` | |
| WHERE refresh_date = DATE_SUB(CURRENT_DATE, INTERVAL 1 DAY); | |
| -- data for 2 days: 955 MB scanned | |
| SELECT * | |
| FROM `bigquery-public-data.google_trends.international_top_terms` | |
| WHERE refresh_date > DATE_SUB(CURRENT_DATE, INTERVAL 3 DAY); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SELECT term, | |
| rank, | |
| AVG(score) AS avg_score | |
| FROM `bigquery-public-data.google_trends.international_top_terms` | |
| WHERE refresh_date = DATE_SUB(CURRENT_DATE, INTERVAL 1 DAY) | |
| AND country_name = "United Kingdom" | |
| GROUP BY term, rank | |
| ORDER BY rank ASC; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def fizzbuzz(n): | |
| return [('' + 'Fizz' * (not x % 3) + 'Buzz' * (not x % 5)) or x for x in range(1, n+1)] |
Hello Le Wagon 👋
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from pandas import DataFrame | |
| def main(): | |
| path = 'input/mail.mbox' | |
| mails = get_mails(path) | |
| unsub_links = add_unsubscribe(mails) | |
| df = DataFrame(unsub_links).T | |
| df = df.sort_values(by='count', ascending=False) | |
| df.to_csv('output.csv') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import re | |
| def add_unsubscribe(mails: List, unsub_links: dict = {}) -> dict: | |
| for mail in mails: | |
| #getting sender | |
| sender_line = mail.split('\n')[0] #first line of the mail | |
| sender_words = sender_line.split(' ')[1:] #removes the 'From: ' part | |
| sender = ' '.join(sender_words) #recreates the name string | |
| if 'Q?' in sender: | |
| sender = re.findall('.Q.?(.*?)\?', sender)[0] #removing some char coding |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from typing import List | |
| def get_mails(path: str, limit: int = None) -> List[str]: | |
| '''Extract emails from an .mbox file.''' | |
| mails = [] | |
| c = -1 | |
| mail = str() | |
| with open(path, 'r', encoding = 'UTF-8') as file: | |
| for line in file: #read every line | |
| if c == limit: break |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| print(token) | |
| >> T2_wi8XsUpJrbD0BHQH4vX0BrSuYV0D88sVrQ_wMgApU... |