Skip to content

Instantly share code, notes, and snippets.

@fferegrino
Last active November 21, 2017 14:02
Show Gist options
  • Save fferegrino/0f345dc29f7f2b5627f3986922b1bdfd to your computer and use it in GitHub Desktop.
Save fferegrino/0f345dc29f7f2b5627f3986922b1bdfd to your computer and use it in GitHub Desktop.
quick python snips
with open(file, "r") as f:
for line in f:
print(line)
import datetime
def date_ms(timestamp):
return datetime.datetime.fromtimestamp(timestamp).strftime('%Y-%m-%d %H:%M:%S')
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