Last active
November 21, 2017 14:02
-
-
Save fferegrino/0f345dc29f7f2b5627f3986922b1bdfd to your computer and use it in GitHub Desktop.
quick python snips
This file contains 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
with open(file, "r") as f: | |
for line in f: | |
print(line) |
This file contains 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 datetime | |
def date_ms(timestamp): | |
return datetime.datetime.fromtimestamp(timestamp).strftime('%Y-%m-%d %H:%M:%S') |
This file contains 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 | |
with open(file,"w",newline="\n",encoding="utf-8") as f: | |
writer = csv.writer(f, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL) | |
writer.writerow(("tuple", "cols")) | |
for i in range(10): | |
writer.writerow(("Data", "as tuple" + str(i)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment