Last active
August 29, 2015 14:20
-
-
Save ebertti/6497db36e3a40d980118 to your computer and use it in GitHub Desktop.
AcharLinksEmCsv
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
# coding: utf-8 | |
import csv | |
import sys | |
import re | |
def main(): | |
regra = re.compile(r'http://www.megamamute.com.br/produto/.*') | |
selecionados = set() | |
with open(sys.argv[0], 'rb') as csvfile: | |
arquivo = csv.reader(csvfile, delimiter=';') | |
for linha in arquivo: | |
for item in linha: | |
if regra.match(item): | |
selecionados.add(item) | |
with open(sys.argv[1], 'wb') as unicos: | |
for item in selecionados: | |
unicos.writelines(item) | |
if __name__ == '__main__': | |
main() | |
# RUNINNG: python asd.py entrada.csv saida.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment