On Saturday, 10 January 2015 21:31:25 UTC-6, Denis McMahon wrote: > On Fri, 09 Jan 2015 09:49:25 -0800, semeon.risom wrote: > > > Thank you for the help btw. I think I'm close to a solution, but I'm > > having issue feeding the coordinates from my csv file into the formula. > > > > This is the error I get: > > Traceback (most recent call last): > > File "C:\Users\Owner\Desktop\Stimuli Generation\Coordinates\Generate_w > > corr.py", line 68, in <module> > > makeimg(length, orientation) > > File "C:\Users\Owner\Desktop\Stimuli Generation\Coordinates\Generate_w > > corr.py", line 40, in makeimg > > orientation = orientation % 180 > > TypeError: unsupported operand type(s) for %: 'list' and 'int' > >>>> > >>>> > > and here's the code: > > > > from PIL import Image, ImageDraw from numpy import math > > > > # import csv import csv f = open('C:\Users\Owner\DesktopStimuli > > Generation\Coordinates\file.csv', 'rb') > > rdr = csv.reader(f) > > f.seek(0) > > i = 0 a = [] > > b = [] > > for row in rdr: > > a.append(row[0]) > > b.append(row[1]) > > This makes a and b both lists > > Having read some other errors that you are having, you need to make sure > that these items are numeric and not string data > > for row in rdr: > a.append(int(row[0])) > b.append(int(row[1])) > > > # using lists of values for length in [a]: > > for orientation in [b]: > > makeimg(length, orientation) > > This puts list a inside another list, and puts list b inside another > list, and then passes the whole of lists a and b in the first call to > makeimg. > > makeimg expects 2 integer parameters on each call, not two lists! > > As you have already created lists, you don't need to wrap them inside > another list. > > # using lists of values > for length in a: > for orientation in b: > makeimg(length, orientation) > > -- > Denis McMahon, denismfmcma...@gmail.com
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...). -- https://mail.python.org/mailman/listinfo/python-list