Re: [Tutor] UnicodeDecodeError while parsing a .csv file.

2013-10-28 Thread eryksun
On Mon, Oct 28, 2013 at 7:49 PM, Steven D'Aprano wrote: > > By default Python 3 uses UTF-8 when reading files. As the error below > shows, your file actually isn't UTF-8. Modules default to UTF-8, but io.TextIOWrapper defaults to the locale preferred encoding. To handle terminals, it first tries

Re: [Tutor] UnicodeDecodeError while parsing a .csv file.

2013-10-28 Thread SM
Thanks to all, for so much information. I just checked that the encoding is Latin-1 and it works when I use it in the file open call. (instead of ignoring it). On Mon, Oct 28, 2013 at 7:54 PM, Danny Yoo wrote: > Hi Sm, > > Note: if possible, I would strongly suggest reusing csv.reader rather th

Re: [Tutor] UnicodeDecodeError while parsing a .csv file.

2013-10-28 Thread SM
Hi Steven, Thanks, very much, for the very detailed reply. It was very useful. This is just a utility script to read some sentiment analysis data to manipulate the positive and negative sentiments of multiple people into a single sentiment per line. So the data I got was from some public domain whi

Re: [Tutor] UnicodeDecodeError while parsing a .csv file.

2013-10-28 Thread SM
Hi Bob, Thanks, very much, for your quick and detailed reply. This is just a utility script to read some sentiment analysis data to manipulate the positive and negative sentiments of multiple people into a single sentiment per line. The data I got was from some public domain which I have no control

Re: [Tutor] UnicodeDecodeError while parsing a .csv file.

2013-10-28 Thread Danny Yoo
Hi Sm, Note: if possible, I would strongly suggest reusing csv.reader rather than reinvent this. It comes in Python's Standard Library: http://docs.python.org/3/library/csv.html#module-csv ​ --- Anyway, to your question. Do you know what is the encoding of your input file? (And if you don

Re: [Tutor] UnicodeDecodeError while parsing a .csv file.

2013-10-28 Thread Mark Lawrence
On 28/10/2013 22:13, SM wrote: Hello, I have an extremely simple piece of code which reads a .csv file Could have fooled me, why not use the stdlib csv module? For the UnicodeDecodeError Bob Gailer has already pointed you in the right direction. -- Python is the second best programming lang

Re: [Tutor] UnicodeDecodeError while parsing a .csv file.

2013-10-28 Thread Steven D'Aprano
On Mon, Oct 28, 2013 at 06:13:59PM -0400, SM wrote: > Hello, > I have an extremely simple piece of code which reads a .csv file, which has > 1000 lines of fixed fields, one line at a time, and tries to print some > values. > > 1 #!/usr/bin/python3 > 2 # > 3 import sys, time, re, os > 4 >

Re: [Tutor] UnicodeDecodeError while parsing a .csv file.

2013-10-28 Thread bob gailer
On 10/28/2013 6:13 PM, SM wrote: > Hello, Hi welcome to the Tutor list > I have an extremely simple piece of code which could be even simpler - see my comments below > which reads a .csv file, which has 1000 lines of fixed fields, one line at a time, and tries to print some values. > > 1 #!

[Tutor] UnicodeDecodeError while parsing a .csv file.

2013-10-28 Thread SM
Hello, I have an extremely simple piece of code which reads a .csv file, which has 1000 lines of fixed fields, one line at a time, and tries to print some values. 1 #!/usr/bin/python3 2 # 3 import sys, time, re, os 4 5 if __name__=="__main__": 6 7 ifd = open("infile.csv", 'r')

Re: [Tutor] Graphs and Python

2013-10-28 Thread Albert-Jan Roskam
On Mon, 10/28/13, Mark Lawrence wrote: Subject: Re: [Tutor] Graphs and Python To: tutor@python.org Date: Monday, October 28, 2013, 7:38 PM On 28/10/2013 16:27, SAMADI, BEHROKH wrote: > Hi > I need to use a graph manipulation and visualization

Re: [Tutor] Graphs and Python

2013-10-28 Thread Mark Lawrence
On 28/10/2013 16:27, SAMADI, BEHROKH wrote: Hi I need to use a graph manipulation and visualization package with Python 3.3, on MS Windows XP. I have tried a number of packages, graphviz, pygraphviz, but, cannot get them working, mostly with syntax errors, possibly due to the mismatch of pyth

Re: [Tutor] Graphs and Python

2013-10-28 Thread Alan Gauld
On 28/10/13 16:27, SAMADI, BEHROKH wrote: I need to use a graph manipulation and visualization package with Python 3.3, on MS Windows XP. I have tried a number of packages, graphviz, pygraphviz, but, cannot get them working, mostly with syntax errors, possibly due to the mismatch of python v

Re: [Tutor] Question about conditions and empty values

2013-10-28 Thread Alan Gauld
On 28/10/13 15:59, Shelby Martin wrote: I use the Python GUI called IDLE. As far as I can tell, it doesn't show me any error messages, How are you running the program in IDLE? When I type the code into a new edit window, save it and run it from within IDLE the error trace appears in the Python

Re: [Tutor] Question about conditions and empty values

2013-10-28 Thread Shelby Martin
I use the Python GUI called IDLE. As far as I can tell, it doesn't show me any error messages, but when the program shuts down suddenly due to a coding error, some sort of text pops up very briefly on the screen before it shuts down. Sorry, I'm a complete newbie to Python :) And thanks for your hel

[Tutor] Graphs and Python

2013-10-28 Thread SAMADI, BEHROKH
Hi I need to use a graph manipulation and visualization package with Python 3.3, on MS Windows XP. I have tried a number of packages, graphviz, pygraphviz, but, cannot get them working, mostly with syntax errors, possibly due to the mismatch of python versions. Please let me know what packa