> Learn how to use a database. Creating and managing a > big collection of directories to handle small data items is the > wrong approach to data storage. > > John Nagle
Or not... Using directories may be a way to do rapid prototyping, and check quickly how things are going internally, without needing to resort to complex database interfaces. Just a quote from the history of usenet: I wrote the very first version of netnews as a 150-line shellscript. It had multiple newsgroups and cross-posting; newsgroups were directories and cross-posting was implemented as multiple links to the article. It was far too slow to use for production, but the flexibility permitted endless experimentation with the protocol design. -- Steven M. Bellovin http://www.linuxtopia.org/online_books/programming_books/art_of_unix_programming/ch14s04_2.html for the question of the OP: import string import os namefile="..." for line in open("foobar").readlines() dirname,number=string.split(line) os.system("mkdir "+dirname) f=open(dirname+"/"+namefile,"w") f.write("TEXT..."+number) f.close() Portability can be improved by using os.path or something like that. John Nagle <na...@animats.com> wrote: > On 4/30/2012 8:19 AM, deltaquat...@gmail.com wrote: >> Hi, >> >> I would like to automate the following task under Linux. I need to create a >> set of directories such as >> >> 075 >> 095 >> 100 >> 125 >> >> The directory names may be read from a text file foobar, which also contains >> a number corresponding to each dir, like this: >> >> 075 1.818 >> 095 2.181 >> 100 2.579 >> 125 3.019 >> >> >> In each directory I must copy a text file input.in. This file contains two >> lines which need to be edited: > -- http://mail.python.org/mailman/listinfo/python-list