Generate jpg files using line length (pixels) and orientation (degrees)
Denis McMahon
denismfmcmahon at gmail.com
Sun Jan 11 14:56:57 EST 2015
On Sun, 11 Jan 2015 11:41:28 -0800, semeon.risom wrote:
> The code is working correctly. Thank you! The only change I had to make
> was referring to it as a float instead of an integer.
>
> The images are generating, however I'm noticing that it's making an
> image for every possible pair in each list (i.e. Image 1: a1 and b1;
> Image 2: a1 and b2; Image 3: a1 and b3....) instead of an image for each
> row (e.g. Image 1: a1 and b1; Image 2: a2 and b2; Image 3: a3 and
> b3...).
Try these changes:
# before the csv reader, declare a single list
params = []
# in the csv reader, append each pair of params to the list as
# a tuple
for row in rdr:
params.append( ( int(row[0]), int(row[1]) ) )
# use the lists of tuples to generate one image per tuple
for item in params:
makeimg(item[0], item[1])
#####################################################
You could also skip the list generation entirely.
After the main function definition:
f = open(filename, 'r')
rdr = csv.reader(f)
for row in rdr:
makeimg(int(row[0]), int(row[1]))
Also please note that you only need to quote the bits of the post that
you are replying to to give context, not the whole post.
--
Denis McMahon, denismfmcmahon at gmail.com
More information about the Python-list
mailing list