Skip to content

Instantly share code, notes, and snippets.

@Jongbhin
Last active March 12, 2020 00:34
Show Gist options
  • Save Jongbhin/87df9a2f980418ccab2be1b282d8a975 to your computer and use it in GitHub Desktop.
Save Jongbhin/87df9a2f980418ccab2be1b282d8a975 to your computer and use it in GitHub Desktop.
[image purify] #image # 11st #url #purify
import csv
import gzip
import os
file_name = 'input0000'
out_file_name = 'input0000.fix'
if os.path.exists(out_file_name):
os.remove(out_file_name)
with open(file_name) as ifd, open(out_file_name, mode='a') as ofd:
csv_reader = csv.reader(ifd, delimiter=',', quoting=csv.QUOTE_NONE)
csv_writer = csv.writer(ofd, delimiter=',')
try:
for row in csv_reader:
url = row[2].split(',')[0].strip('"')
if url.startswith('/RoL'):
url = url[4:]
out_row = [row[0], row[1], url]
csv_writer.writerow(out_row)
except Exception as error:
print error
def purify(url):
url = url.split(',')[0].strip('"')
if url.startswith('/RoL'):
url = url[4:]
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment