Created
March 16, 2016 13:04
-
-
Save palcu/3c8e92a38905a3bb79b8 to your computer and use it in GitHub Desktop.
Mapper for Disqus
This file contains hidden or 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
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