jweinst1
11/27/2015 - 6:48 AM

small script for creating a new directory in python and writing files to it.

small script for creating a new directory in python and writing files to it.

#file for creating the db directory
import os
#creates a directory in python
def createdb(directory):
    if not os.path.exists(directory):
        os.makedirs(directory)
#creates file in a subdirectory, named directory
def write_todb(name, content, directory):
    target = open(os.path.join(directory, name), 'w')
    target.write(content)
    target.close()