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: the language and the tool to help you!
Written by
Arthur Camberlein