I'm not an experienced Python developer but if I do the following (Python 2.7)
with open(csvfile, 'rb') as inputfile:
reader = csv.DictReader(inputfile) # or csv.reader(inputfile)
variables['reader'] = reader
print template.merge(variables, loader = loader)
with this template
#foreach($row in $reader)
## use $row here
#end
I get an error
ValueError: value for $row is not iterable in #foreach: <csv.DictReader instance at 0x02C38030>
but I have to change
variables['reader'] = reader
to
variables['reader'] = list(reader)
to get it to work. Is that expected behaviour? It was my impression that the csv reader could be treated as iterable, seeing as in standard python this works:
I'm not an experienced Python developer but if I do the following (Python 2.7)
with this template
I get an error
but I have to change
to
to get it to work. Is that expected behaviour? It was my impression that the csv reader could be treated as iterable, seeing as in standard python this works: