Skip to content

Instantly share code, notes, and snippets.

@giovaneliberato
Last active August 29, 2015 14:08
Show Gist options
  • Save giovaneliberato/969b5d824e02b5d60217 to your computer and use it in GitHub Desktop.
Save giovaneliberato/969b5d824e02b5d60217 to your computer and use it in GitHub Desktop.
Slice json files in small pieces
import json
with open("erbopencellid.json") as fixtures:
conteudo = json.loads("".join(fixtures.readlines()))
tamanho = len(conteudo)
inicio = 0
range_ = fim = tamanho / 10
for i in range(1, 11):
fname = "erbopencellid%d.json" % i
print fname, inicio, fim
f = open(fname, 'w')
f.write(json.dumps(conteudo[inicio:fim]))
inicio = fim
fim += range_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment