Created
February 6, 2013 21:26
Python script to map old to new URLs for migrating Disqus threads.
This file contains 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
# coding: utf-8 | |
import pandas as pd | |
def fix(url): | |
# remove www subdomain | |
url = url.replace('://www.', '://') | |
# add slash if URL doesn't end with .html | |
if not url.endswith('html'): | |
url = url.rstrip('/') + '/' | |
return url | |
df = pd.io.parsers.read_csv('ramiro.org.disqus.csv', header=None) | |
df['X.2'] = df['X.1'].map(fix) | |
df.to_csv('fixed.csv', header=False, index=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment