Created
July 21, 2017 11:33
-
-
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
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 | |
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