How do I render the data of a arquivo.txt
in a Django template?
file content:
1;'one';'foo'
2;'two';'bar'
I return in the template
1 - one - foo
2 - two - bar
Any tips on where I start?
Following the link
I've tried the following:
def display_text_file():
with open('output.csv', 'rt') as f:
r = csv.reader(f, delimiter=';')
fields = r.next()
for row in r:
items = zip(fields, row)
item = {}
for (name, value) in items:
item[name] = value.strip()
Now how do I return this in the context of the view to iterate through the values in the template?
I've tried
{% for line in lines %}
<p>{{ line.id }}</p>
{% endfor %}