[issue26116] CSV-module. The example code don't work. Have to be: reader = csv.reader(csvfile, dialect=dialect)

2016-01-15 Thread Василь Коломієць

Василь Коломієць added the comment:

))
Thanks!
Be happy!

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26116] CSV-module. The example code don't work. Have to be: reader = csv.reader(csvfile, dialect=dialect)

2016-01-14 Thread Georg Brandl

Georg Brandl added the comment:

We'll need at least the two full examples (one not working, one working) to 
make a call here.

--
nosy: +georg.brandl

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26116] CSV-module. The example code don't work. Have to be: reader = csv.reader(csvfile, dialect=dialect)

2016-01-14 Thread Василь Коломієць

Changes by Василь Коломієць :


Added file: http://bugs.python.org/file41620/CSV-ex.png

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26116] CSV-module. The example code don't work. Have to be: reader = csv.reader(csvfile, dialect=dialect)

2016-01-14 Thread Василь Коломієць

Василь Коломієць added the comment:

Thanx a lot.
And sorry.
But with ..., dialect=dialect,  the same code is working.
.
Ok. i'll try to understand.
With best wishes - VK.

С уважением,
Василий Коломиец
+38050 45 22 559

2016-01-15 0:18 GMT+02:00 SilentGhost <rep...@bugs.python.org>:

>
> SilentGhost added the comment:
>
> Vasyl, this line in your code is causing the problem:
>
> for row in readed:
>
> The error reasonably clear states that it's due to your `fieldnames'
> parameter being non-iterable. Again, this has nothing whatsoever to do with
> `dialect' argument and documentation of Sniffer.
>
> Please, do not open new issues about this. This is not a issue with csv
> library or its documentation. Try to use use stackoverflow or python-tutor
> list to get help on this.
> https://mail.python.org/pipermail/tutor/
>
> --
> nosy: +SilentGhost
> resolution:  -> not a bug
> stage:  -> resolved
> status: open -> closed
>
> ___
> Python tracker <rep...@bugs.python.org>
> <http://bugs.python.org/issue26116>
> _______
>

------
title: CSV-module. The example code don't work.Have to be: reader = 
csv.reader(csvfile, dialect=dialect) -> CSV-module. The example code don't 
work. Have to be: reader = csv.reader(csvfile, dialect=dialect)

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue26116>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26116] CSV-module. The example code don't work. Have to be: reader = csv.reader(csvfile, dialect=dialect)

2016-01-14 Thread Василь Коломієць

Василь Коломієць added the comment:

I am very happy!
Thx for attention to my opinion.
Sorry for my english.

so - in attachment two codes and source csv-file.

With best wishes,
Vasyl Kolomiets.
+38050 45 22 559

2016-01-15 0:38 GMT+02:00 Georg Brandl :

>
> Georg Brandl added the comment:
>
> We'll need at least the two full examples (one not working, one working)
> to make a call here.
>
> --
> nosy: +georg.brandl
>
> ___
> Python tracker 
> 
> ___
>

--
Added file: http://bugs.python.org/file41617/may_be-error_csv_exmpl.py
Added file: http://bugs.python.org/file41618/from_to_proportions.csv
Added file: http://bugs.python.org/file41619/may_be-good_csv_exmpl.py

___
Python tracker 

___from tkinter import *
from PIL import Image
import csv

filename = "from_to_proportions.csv"
with open(filename) as csvfile:
dialect=csv.Sniffer().sniff(csvfile.read(1024))
csvfile.seek(0)
print(dialect)
readed = csv.DictReader(csvfile, dialect)
for row in readed:
print(row)
print (row["from_id"],row["from_name"],row['to_id'],row['to_name'],
   row['barcodes_percentage'],row['rows_to_be'])

from_id;from_name;to_id;to_name;barcodes_percentage;rows_to_be
1;Київ;2;Дніпро;75%;4
1;Київ;3;Запоріжжя;10%;4
1;Київ;4;Одеса;15%;4
1;Київ;5;Львів;0%;4
2;Дніпро;1;Київ;50%;4
2;Дніпро;3;Запоріжжя;10%;4
2;Дніпро;4;Одеса;25%;4
2;Дніпро;5;Львів;15%;4
3;Запоріжжя;1;Київ;0%;4
3;Запоріжжя;2;Дніпро;33%;4
3;Запоріжжя;4;Одеса;33%;4
3;Запоріжжя;5;Львів;34%;4
4;Одеса;1;Київ;25%;4
4;Одеса;2;Дніпро;25%;4
4;Одеса;3;Запоріжжя;25%;4
4;Одеса;5;Львів;25%;4
5;Львів;1;Київ;0%;4
5;Львів;2;Дніпро;50%;4
5;Львів;3;Запоріжжя;15%;4
5;Львів;4;Одеса;35%;4
from tkinter import *
from PIL import Image
import csv

filename = "from_to_proportions.csv"
with open(filename) as csvfile:
dialect=csv.Sniffer().sniff(csvfile.read(1024))
csvfile.seek(0)
print(dialect)
readed = csv.DictReader(csvfile, dialect=dialect)
for row in readed:
print(row)
print (row["from_id"],row["from_name"],row['to_id'],row['to_name'],
   row['barcodes_percentage'],row['rows_to_be'])

___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26116] CSV-module. The example code don't work. Have to be: reader = csv.reader(csvfile, dialect=dialect)

2016-01-14 Thread SilentGhost

SilentGhost added the comment:

Vasyl, this line in your code is causing the problem:

for row in readed:

The error reasonably clear states that it's due to your `fieldnames' parameter 
being non-iterable. Again, this has nothing whatsoever to do with `dialect' 
argument and documentation of Sniffer. 

Please, do not open new issues about this. This is not a issue with csv library 
or its documentation. Try to use use stackoverflow or python-tutor list to get 
help on this.
https://mail.python.org/pipermail/tutor/

--
nosy: +SilentGhost
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26116] CSV-module. The example code don't work. Have to be: reader = csv.reader(csvfile, dialect=dialect)

2016-01-14 Thread Georg Brandl

Georg Brandl added the comment:

Thanks!  Now the reason is clear: You use csv.DictReader instead of csv.reader. 
csv.DictReader has a different argument list - for DictReader the second 
argument is `fieldnames`.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com