Best approach to create humongous amount of files

Chris Angelico rosuav at gmail.com
Wed May 20 08:58:05 EDT 2015


On Wed, May 20, 2015 at 9:44 PM, Parul Mogra <scoria.799 at gmail.com> wrote:
> My objective is to create large amount of data files (say a million *.json
> files), using a pre-existing template file (*.json). Each file would have a
> unique name, possibly by incorporating time stamp information. The files
> have to be generated in a folder specified.
>
> What is the best strategy to achieve this task, so that the files will be
> generated in the shortest possible time? Say within an hour.

If they're to be created within an hour, timestamp of creation
probably isn't useful, but if you have internal data to use as the
file name, that would work. Otherwise, try a simple sequential
integer.

All you'd need would be a loop that creates a bunch of files... most
of your code will be figuring out what parts of the template need to
change. Not too difficult.

ChrisA



More information about the Python-list mailing list