Skip to content

Instantly share code, notes, and snippets.

@yaph
Created February 6, 2013 21:26
Python script to map old to new URLs for migrating Disqus threads.
# 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