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 csv | |
def import_csv(filename=None, import_all_columns=False, columns_to_import=None, remove_duplicates=False): | |
""" | |
Add contents of specified columns in .csv file to a list of dictionaries. | |
:param filename: string | |
:param import_all_columns: bool | |
:param columns_to_import: list |
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 pytz | |
from datetime import date, datetime, time | |
def today_to_midnight_utc(local_tz='UTC'): | |
""" | |
Returns today's date (local timezone) as a midnight UTC timestamp. | |
e.g. If date is 04/20/18, and server timezone is America/Los_Angeles: | |
today_to_midnight_utc(local_tz='America/Los_Angeles') | |
>> 1524182400 |
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
[ | |
{ | |
"city": "New York", | |
"growth_from_2000_to_2013": "4.80%", | |
"latitude": 40.7127837, | |
"longitude": -74.0059413, | |
"population": 8405837, | |
"rank": 1, | |
"state": "New York", | |
"timezone": "America/New_York" |