Skip to content

Instantly share code, notes, and snippets.

@palcu
Created March 16, 2016 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save palcu/3c8e92a38905a3bb79b8 to your computer and use it in GitHub Desktop.
Save palcu/3c8e92a38905a3bb79b8 to your computer and use it in GitHub Desktop.
Mapper for Disqus
import csv
urls = []
with open('links.csv') as stream:
for line in stream:
url = line.strip()
if 'http' in url and 'https' not in url:
better_url = url.replace('http', 'https', 1) # replace only first occurence
urls.append([url, better_url])
with open('mapped.csv', 'w', newline='') as csvfile:
csvwriter = csv.writer(csvfile)
for url in urls:
csvwriter.writerow(url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment