Skip to content

Instantly share code, notes, and snippets.

@osoda
Created November 8, 2018 11:34
Show Gist options
  • Save osoda/69f21664352a55540ec18781c0ab7119 to your computer and use it in GitHub Desktop.
Save osoda/69f21664352a55540ec18781c0ab7119 to your computer and use it in GitHub Desktop.
Give a multiple lists in ouput file, whit the files in a dir; every list have a static amount files
#!/usr/bin/python
import os, math
for root, dirs, files in os.walk("./manual"):
n = int(input(raw_input("Ingrese el numero de archivos en el que se particionara: ")))
dbs = ''
length =len(files)
cantArchives = int(math.ceil(float(length)/n))
print(str(length)+' nombres de db seran guardadas en '+str(cantArchives)+' archivos')
for i,filename in enumerate(files, start=1):
dbs +=filename+'\n'
if(i%n==0 or i==length):
x = int(math.ceil(float(i)/n))
f = os.path.join(root,filename)
a = open("outputs/dbs%s.txt" %x,"w")
a.write(str(dbs))
print(dbs+ str(x))
dbs = ''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment