Generate jpg files using line length (pixels) and orientation (degrees)
Denis McMahon
denismfmcmahon at gmail.com
Sat Jan 10 19:32:18 EST 2015
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, denismfmcmahon at gmail.com
More information about the Python-list
mailing list