Skip to content

Instantly share code, notes, and snippets.

@tyteen4a03
Created July 21, 2017 11:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tyteen4a03/6897576851d1db764fb73030586483b9 to your computer and use it in GitHub Desktop.
Save tyteen4a03/6897576851d1db764fb73030586483b9 to your computer and use it in GitHub Desktop.
a quick and dirty way to convert US dates to British dates generated by Facebook Page Insights
import csv
import re
with open("test.csv", "r+") as f:
with open("testoutput.csv", "w+") as g:
reader = csv.DictReader(f)
writer = csv.DictWriter(g, reader.fieldnames)
for row in reader:
date = row["Posted"]
m = re.match(r"^(\d\d)/(\d\d)(.*)$", date)
month = m.group(1)
day = m.group(2)
rest = m.group(3)
row["Posted"] = day + "/" + month + rest
writer.writerow(row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment