This is what i have done and its giving me error. #!/usr/bin/env python
import csv, sys, os filename = (sys.argv[1]) reader = csv.reader(open(filename, "rb"), delimiter=',', quoting=csv.QUOTE_NONE) try: #for row in reader: for fmodes,fname in reader: os.chmod(fname,fmodes) except csv.Error, e: sys.exit('file %s, line %d: %s' % (filename, reader.line_num, e)) testserver:~> ./parsecsv.py chown.csv Traceback (most recent call last): File "./promote2prod.py", line 10, in ? os.chmod(fname,fmodes) TypeError: an integer is required Please help I'm a complete newbie to python. Many thanks. Jay On Thu, Dec 4, 2008 at 4:32 AM, Tino Wildenhain <[EMAIL PROTECTED]> wrote: > MRAB wrote: > >> Jay Jesus Amorin wrote: >> >>> This is how i do it, but it runs with error. Kindly help >>> >>> >>> #!/usr/bin/env python >>> >>> import csv, sys, os >>> filename = (sys.argv[1]) >>> reader = csv.reader(open(filename, "rb"), delimiter=',', >>> quoting=csv.QUOTE_NONE) >>> >>> try: >>> for row in reader: >>> os.popen("chown row[0] row[1]") >>> >> This should be: >> >> os.popen("chown %s %s" % (row[0], row[1])) >> >> or: >> >> os.popen("chown %s %s" % tuple(row)) >> > > No, it should really be os.popen(("chown",row[0],row[1])) > or better yet, > > for fmodes,fname in reader: > os.popen(("chown",fmodes,fname)) > > or even plus better: > > for fmodes,fname in reader: > os.chmod(fname,fmodes) > > (Both my examples avoid problems with unquoted filenames) > > Regards > Tino > > -- > http://mail.python.org/mailman/listinfo/python-list > >
-- http://mail.python.org/mailman/listinfo/python-list