[Tutor] Parsing data from a set of files iteratively
Steven D'Aprano
steve at pearwood.info
Wed May 30 02:09:28 CEST 2012
Steven D'Aprano wrote:
> location = '/Users/spyros/Desktop/3NY8MODELSHUMAN/HomologyModels/'
> zdata = []
> for filename in os.listdir(location):
> zdata.extend(get_zcoords(filename))
Hah, that can't work. listdir returns the name of the file, but not the file's
path, which means that Python will only look in the current directory. You
need something like this:
location = '/Users/spyros/Desktop/3NY8MODELSHUMAN/HomologyModels/'
zdata = []
for filename in os.listdir(location):
zdata.extend(get_zcoords(os.path.join(location, filename)))
Sorry about that.
--
Steven
More information about the Tutor
mailing list