import difflib
import pandas as pd
from datetime import date
date = date.today()
today = date.strftime("%Y-%m-%d")
document = today + "-diff"
document_txt = "data/" + document + ".txt"
document_csv = "data/" + document + ".csv"
with open('robots-live.txt') as robots_live, open('robots-staging2.txt') as robots_staging:
diff = difflib.unified_diff(
robots_live.readlines(),
robots_staging.readlines(),
fromfile='robots-live.txt',
tofile='robots-staging.txt',
)
# for line in diff:
# print(line)
with open(document_txt, 'w') as outfile:
for line in diff:
outfile.write(line)
df = pd.DataFrame(diff, columns=['diff'])
df.to_csv(document_csv, index=False)
Diff date usage in Python
Written by Arthur Camberlein | Published on & updated on
Learn more with the article FAQ
Diff date usage in Python - FAQs
Blog post topic: Data, Python : le langage et l'outil pour vous aider !
Written by Arthur Camberlein
With more than 10 years of experience in Marketing, Web Marketing and SEO, Arthur is specialized in Tech SEO and Data Analysis. He is currently working at Shopify, but all the views on this blog & website are his own.