Created
July 5, 2012 03:06
-
-
Save juanpabloaj/3050904 to your computer and use it in GitHub Desktop.
busqueda del 10000 en varios archivos
This file contains 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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import os | |
import shutil | |
import random | |
def verificar(path): | |
# verificar que el archivo tiene un 10000 | |
archivo = open(path,'r') | |
for linea in archivo: | |
#print linea.replace('\n','') | |
if '10000' in linea: | |
return True | |
local = '.' | |
destino = '/out' | |
nuevo_dir = local + destino | |
if not os.path.exists(nuevo_dir): | |
os.mkdir(nuevo_dir) | |
for dirname, dirnames, filenames in os.walk(local): | |
#print dirname, filenames | |
if 'dir' in dirname: | |
for filename in filenames: | |
if '.txt' in filename: | |
fullname = os.path.join(dirname,filename) | |
#print fullname | |
if verificar(fullname): | |
nuevo_file = nuevo_dir+'/copia_'+filename | |
shutil.copyfile(fullname,nuevo_file) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment