[issue33158] Add fileobj property to csv reader and writer objects

2021-11-21 Thread Irit Katriel
Change by Irit Katriel : -- resolution: -> rejected stage: -> resolved status: open -> closed ___ Python tracker ___ ___

Re: CSV reader ignore brackets

2019-09-26 Thread Piet van Oostrum
Skip Montanaro writes: > How about just replacing *\(([^)]*)\)* with *"\1"* in a wrapper class's > line reading method? (I think I have the re syntax approximately right.) > The csv reader will "just work". Again, nesting parens not allowed. > > Skip here

Re: CSV reader ignore brackets

2019-09-25 Thread Skip Montanaro
> Besides, the point isn't the shortest code but to illustrate the idea > of handling special syntax. In my defense, I was typing on my phone while watching a show on Netflix. I was hardly in a position to test any code. :-) As you indicated though, the problem is under-specified (nesting?,

Re: CSV reader ignore brackets

2019-09-24 Thread Cameron Simpson
es (needest at start and end) but not trying to hit things in one go. Better to match exactly the special case you expect and then scour of mismatches than to incorrectly match and have that mistake buried in the data. (I think I have the re syntax approximately right.) The csv reader wil

Re: CSV reader ignore brackets

2019-09-24 Thread Skip Montanaro
How about just replacing *\(([^)]*)\)* with *"\1"* in a wrapper class's line reading method? (I think I have the re syntax approximately right.) The csv reader will "just work". Again, nesting parens not allowed. Skip -- https://mail.python.org/mailman/listinfo/python-list

Re: CSV reader ignore brackets

2019-09-24 Thread MRAB
On 2019-09-25 00:09, Cameron Simpson wrote: On 24Sep2019 15:55, Mihir Kothari wrote: I am using python 3.4. I have a CSV file as below: ABC,PQR,(TEST1,TEST2) FQW,RTE,MDE Really? No quotes around the (TEST1,TEST2) column value? I would have said this is invalid data, but that does not help

Re: CSV reader ignore brackets

2019-09-24 Thread Cameron Simpson
On 24Sep2019 15:55, Mihir Kothari wrote: I am using python 3.4. I have a CSV file as below: ABC,PQR,(TEST1,TEST2) FQW,RTE,MDE Really? No quotes around the (TEST1,TEST2) column value? I would have said this is invalid data, but that does not help you. Basically comma-separated rows, where

CSV reader ignore brackets

2019-09-24 Thread Mihir Kothari
Hi Team, I am using python 3.4. I have a CSV file as below: ABC,PQR,(TEST1,TEST2) FQW,RTE,MDE Basically comma-separated rows, where some rows have a data in column which is array like i.e. in brackets. So I need to read the file and treat such columns as one i.e. do not separate based on comma

[issue33158] Add fileobj property to csv reader and writer objects

2018-03-27 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > A fileobj property would be convenient, as you otherwise, for example, need > to pass an extra argument to routines that need both the csv object and the > underlying file object. But you should already have this object for

[issue33158] Add fileobj property to csv reader and writer objects

2018-03-27 Thread Samwyse
ibrary (Lib) messages: 314538 nosy: samwyse priority: normal severity: normal status: open title: Add fileobj property to csv reader and writer objects type: enhancement versions: Python 2.7, Python 3.8 ___ Python tracker <rep...@bugs.python.org> <https://

[issue30034] csv reader chokes on bad quoting in large files

2017-04-15 Thread Keith Erskine
Keith Erskine added the comment: OK Terry. Thank you everybody for your thoughts and suggestions. -- ___ Python tracker ___

[issue30034] csv reader chokes on bad quoting in large files

2017-04-14 Thread Terry J. Reedy
Terry J. Reedy added the comment: Keith, while I sympathize with the request, I am going to agree with the others and close this. As I see it, csv exists to solve a particular problem. We want a printable file of records and text fields with visible field and record separators, but we may

[issue30034] csv reader chokes on bad quoting in large files

2017-04-11 Thread Keith Erskine
Keith Erskine added the comment: I should have said, Peter, an odd number of quotes does not necessarily mean the quoting is bad. For example, a line of: a,b",c will parse fine as ['a', 'b"', 'c']. Figuring out bad quoting is not easy, but if we know that there are no multiline fields in the

[issue30034] csv reader chokes on bad quoting in large files

2017-04-11 Thread Keith Erskine
Keith Erskine added the comment: The csv reader already supports bad CSV - that's what I believe "strict" is for - but only in one specific scenario. My request is to make that "strict" attribute a bit more useful. Thank you for your suggestion, Peter. I have toyed with

[issue30034] csv reader chokes on bad quoting in large files

2017-04-11 Thread Peter Otten
Peter Otten added the comment: While I don't think that the csv module should second-guess broken input you might consider "fixing" your data on the fly: def close_quote(line): if line.count('"') % 2: line = line.rstrip("\n") + '"\n' return line with open("data.csv") as f:

[issue30034] csv reader chokes on bad quoting in large files

2017-04-10 Thread Raymond Hettinger
Raymond Hettinger added the comment: > In my experience CSV files with fields with embedded newlines > are pretty common. I don't really think we want to support > invalid CSV files. I concur with David on both points. Also, whether common or not, we don't want to break existing code that

[issue30034] csv reader chokes on bad quoting in large files

2017-04-10 Thread Keith Erskine
Keith Erskine added the comment: As you say, David, however much we would like the world to stick to a given CSV standard, the reality is that people don't, which is all the more reason for making the csv reader flexible and forgiving. The csv module can and should be used for more than just

[issue30034] csv reader chokes on bad quoting in large files

2017-04-10 Thread R. David Murray
R. David Murray added the comment: Well, ETL is semi-standardized. Try dealing with csv files exported from excel spreadsheets written by non-programmers :) "e"X is not a quoting the csv module will produce, but I don't think it is a csv error. insofar as csv has a standard, it is a defacto

[issue30034] csv reader chokes on bad quoting in large files

2017-04-10 Thread Keith Erskine
Keith Erskine added the comment: The csv reader already handles a certain amount of bad formatting. For example, using default behavior, the following file: a,b,c d,"e"X,f g,h,i is read as: ['a', 'b', 'c'] ['d', 'eX', 'f'] ['g', 'h', 'i'] It seems reasonable that csv shou

[issue30034] csv reader chokes on bad quoting in large files

2017-04-10 Thread R. David Murray
R. David Murray added the comment: In my experience CSV files with fields with embedded newlines are pretty common. I don't really think we want to support invalid CSV files. -- nosy: +r.david.murray ___ Python tracker

[issue30034] csv reader chokes on bad quoting in large files

2017-04-10 Thread Keith Erskine
Keith Erskine added the comment: Perhaps I should add what I would prefer the csv reader to return in my example above. That would be: ['a', 'b', 'c'] ['d', 'e,f'] ['g', 'h', 'i'] Yes, the second line is still mangled but at least the csv reader would carry on and read the third line

[issue30034] csv reader chokes on bad quoting in large files

2017-04-10 Thread Mariatta Wijaya
Changes by Mariatta Wijaya : -- components: +Library (Lib) nosy: +Mariatta ___ Python tracker ___

[issue30034] csv reader chokes on bad quoting in large files

2017-04-10 Thread Keith Erskine
is incorrect, but it would be extremely helpful if the csv reader could be told to stop reading each row of fields when it encounters a newline character, even if it is within a quoted field at the time. At the moment, with large files, the csv reader will typically error out in this situation once

[issue28642] csv reader losing rows with big files and tab delimiter

2016-11-09 Thread Marc Garcia
Marc Garcia added the comment: I agree that for my case, I was using the wrong quoting parameter, and if I specify that my file has no quotes, it works as expected. But I still think that in a different case, when a file do have quotes, but they are not paired, it'd be better to raise an

[issue28642] csv reader losing rows with big files and tab delimiter

2016-11-09 Thread SilentGhost
SilentGhost added the comment: No, the module works exactly as advertised. The default value of quoting parameter might not be suitable for this file, but it suits majority of files out there. The fields in csv can contain line feed, so the line in your example does not have a "missing"

[issue28642] csv reader losing rows with big files and tab delimiter

2016-11-09 Thread Marc Garcia
Marc Garcia added the comment: I could research a bit more on the problem. This is a minimal code that reproduces what happened: from io import StringIO import csv csv_file = StringIO('''1\t"A 2\tB''') reader = csv.reader(csv_file, delimiter='\t') for i, row in

[issue28642] csv reader losing rows with big files and tab delimiter

2016-11-08 Thread SilentGhost
Changes by SilentGhost : -- stage: -> resolved ___ Python tracker ___ ___

[issue28642] csv reader losing rows with big files and tab delimiter

2016-11-08 Thread Marc Garcia
: -> not a bug status: open -> closed title: csv reader loosing rows with big files and tab delimiter -> csv reader losing rows with big files and tab delimiter ___ Python tracker <rep...@bugs.python.org> <http://bugs.pyt

[issue28642] csv reader loosing rows with big files and tab delimiter

2016-11-08 Thread SilentGhost
SilentGhost added the comment: so using quoting=csv.QUOTE_NONE should solve the immediate problem of "losing" lines then, I'm not sure csv module ever supported dealing with corrupted files. -- ___ Python tracker

[issue28642] csv reader loosing rows with big files and tab delimiter

2016-11-08 Thread Matthew Barnett
Matthew Barnett added the comment: I split the file into sections, each containing no more 1000 lines, and tried reading each section. Attached is a zip file of those that didn't return the expected number of rows. The problem appears to be due to unclosed quotes, which cause following lines

[issue28642] csv reader loosing rows with big files and tab delimiter

2016-11-08 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: What is the average number of columns on the file? -- ___ Python tracker ___

[issue28642] csv reader loosing rows with big files and tab delimiter

2016-11-08 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > If I create a new file with all the skipped files, and I read it again in the > same way, around 30% of the rows are skipped. Could you please provide this smaller file? Or better make yet few iterations of keeping only skipped lines until the file will

[issue28642] csv reader loosing rows with big files and tab delimiter

2016-11-08 Thread SilentGhost
SilentGhost added the comment: Could you perhaps make the smaller file make available somewhere? -- nosy: +SilentGhost ___ Python tracker ___

[issue28642] csv reader loosing rows with big files and tab delimiter

2016-11-08 Thread Marc Garcia
: normal status: open title: csv reader loosing rows with big files and tab delimiter versions: Python 3.5 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/i

[issue16013] small csv reader bug

2012-10-20 Thread Serhiy Storchaka
Changes by Serhiy Storchaka storch...@gmail.com: -- resolution: - fixed stage: test needed - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16013 ___

[issue16013] small csv reader bug

2012-09-25 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Here is a test. -- Added file: http://bugs.python.org/file27290/csv_eof_test.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16013 ___

[issue16013] small csv reader bug

2012-09-25 Thread Senthil Kumaran
Senthil Kumaran added the comment: The patch looks good and is doing the right thing, that is, when the, strict mode is passed, it fails and without strict mode, it is printing the parsed list. -- nosy: +orsenthil ___ Python tracker

[issue16013] small csv reader bug

2012-09-25 Thread Roundup Robot
Roundup Robot added the comment: New changeset e9c005676d6e by Senthil Kumaran in branch '3.2': Issue #16013: Fix CSV Reader parsing issue with ending quote characters. Patch by Serhiy Storchaka. http://hg.python.org/cpython/rev/e9c005676d6e New changeset 25f0756deeae by Senthil Kumaran

[issue16013] small csv reader bug

2012-09-25 Thread Roundup Robot
Roundup Robot added the comment: New changeset 5f0465d0e91e by Senthil Kumaran in branch '2.7': 2.7 : Issue #16013: Fix CSV Reader parsing issue with ending quote characters. Patch by Serhiy Storchaka. http://hg.python.org/cpython/rev/5f0465d0e91e

[issue16013] small csv reader bug

2012-09-24 Thread Armin Rigo
to be dropped. -- components: Library (Lib) messages: 171122 nosy: arigo priority: normal severity: normal status: open title: small csv reader bug versions: Python 2.7, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org

[issue16013] small csv reader bug

2012-09-24 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: A shorter example: import csv list(csv.reader(['foo,'])) [] -- nosy: +storchaka type: - behavior versions: +Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16013

[issue16013] small csv reader bug

2012-09-24 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Here is a patch. list(csv.reader(['foo,'])) [['foo', '']] list(csv.reader(['foo,'], strict=1)) Traceback (most recent call last): File stdin, line 1, in module _csv.Error: unexpected end of data list(csv.reader(['foo,^'], escapechar='^')) [['foo', '\n']]

[issue16013] small csv reader bug

2012-09-24 Thread Serhiy Storchaka
Changes by Serhiy Storchaka storch...@gmail.com: Added file: http://bugs.python.org/file27284/csv_eof-3.2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16013 ___

[issue16013] small csv reader bug

2012-09-24 Thread Éric Araujo
Changes by Éric Araujo mer...@netwok.org: -- keywords: +needs review stage: - test needed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue16013 ___

[issue7185] csv reader utf-8 BOM error

2012-04-27 Thread Serhiy Storchaka
Serhiy Storchaka storch...@gmail.com added the comment: I checked out. Files opened in utf-8-sig are seekable. open('test', 'w', encoding='utf-8-sig').write('qwerty\nйцукен\n') open('test', 'r', encoding=utf-8).read() '\ufeffqwerty\nйцукен\n' open('test', 'r', encoding=utf-8-sig).read()

[issue7185] csv reader utf-8 BOM error

2012-04-27 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: Serhiy, the bug is about csv in particular. Can you confirm that using utf-8-sig allows one to process a file with a bom using the csv module? -- ___ Python tracker rep...@bugs.python.org

[issue7185] csv reader utf-8 BOM error

2012-04-27 Thread Serhiy Storchaka
Serhiy Storchaka storch...@gmail.com added the comment: I ran the script above (only replaced 'utf-8' on 'utf-8-sig') and did not see anything strange. I looked at the source (cvs.py and _cvs.c) and also did not see anything that could lead to this effect. If the bug exists, it in utf-8-sig

[issue7185] csv reader utf-8 BOM error

2012-04-27 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: I wasn't sure which script you were referring to, so I checked it myself and got the same results as you: after the seek(0) on the file object opened with utf-8-sig, csv read all the lines in the file, including reading the header line

[issue7185] csv reader utf-8 BOM error

2012-04-27 Thread Serhiy Storchaka
Serhiy Storchaka storch...@gmail.com added the comment: I was referring to the script inlined in the message http://bugs.python.org/issue7185#msg94340 . -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7185

Re: Is it possible to pass CSV Reader Object As Argument to another Python File ???

2011-01-30 Thread bansi
arguments    from stdin and uses csv reader object to read it i.e.    r=csv.reader(sys.stdin)    And then it has to pass csv reader object to another python script    namelookup.py running under Python 2.7 because it uses pyodbc to    connect to database

Re: Is it possible to pass CSV Reader Object As Argument to another Python File ???

2011-01-30 Thread rusi
On Jan 30, 6:31 pm, bansi mail2ba...@gmail.com wrote: On Jan 28, 4:22 pm, Benjamin Kaplan benjamin.kap...@case.edu wrote: You'll need to have Visual C++ 2008 (not 2010) installed for this to work. You can get it for free fromhttp://www.microsoft.com/express/Downloads/if you don't

Re: Is it possible to pass CSV Reader Object As Argument to another Python File ???

2011-01-30 Thread rusi
On Jan 30, 10:35 pm, rusi rustompm...@gmail.com wrote: On Jan 30, 6:31 pm, bansi mail2ba...@gmail.com wrote: Isn't it possible to implement your suggestion without installing Visual C++ 2008 . http://code.google.com/p/pyodbc/wiki/Building#Windows Well... This is what the official site

Re: Is it possible to pass CSV Reader Object As Argument to another Python File ???

2011-01-28 Thread bansi
On Jan 26, 8:31 pm, MRAB pyt...@mrabarnett.plus.com wrote: On 27/01/2011 00:57, bansi wrote: On Jan 26, 6:25 pm, Ethan Furmanet...@stoneleaf.us  wrote: bansi wrote:    First namelookupWrapper.py running under Python 2.6 accept arguments    from stdin and uses csv reader object

Re: Is it possible to pass CSV Reader Object As Argument to another Python File ???

2011-01-28 Thread bansi
accept arguments    from stdin and uses csv reader object to read it i.e.    r=csv.reader(sys.stdin)    And then it has to pass csv reader object to another python script    namelookup.py running under Python 2.7 because it uses pyodbc to    connect to database and iterates thru

Re: Is it possible to pass CSV Reader Object As Argument to another Python File ???

2011-01-28 Thread Benjamin Kaplan
wrote:    First namelookupWrapper.py running under Python 2.6 accept arguments    from stdin and uses csv reader object to read it i.e.    r=csv.reader(sys.stdin)    And then it has to pass csv reader object to another python script    namelookup.py running under Python 2.7

Re: Is it possible to pass CSV Reader Object As Argument to another Python File ???

2011-01-28 Thread bansi
: On Jan 26, 6:25 pm, Ethan Furmanet...@stoneleaf.us  wrote: bansi wrote:    First namelookupWrapper.py running under Python 2.6 accept arguments    from stdin and uses csv reader object to read it i.e.    r=csv.reader(sys.stdin)    And then it has to pass csv reader

Re: Is it possible to pass CSV Reader Object As Argument to another Python File ???

2011-01-28 Thread Benjamin Kaplan
...@mrabarnett.plus.com wrote: On 27/01/2011 00:57, bansi wrote: On Jan 26, 6:25 pm, Ethan Furmanet...@stoneleaf.us  wrote: bansi wrote:    First namelookupWrapper.py running under Python 2.6 accept arguments    from stdin and uses csv reader object to read it i.e.    r

Is it possible to pass CSV Reader Object As Argument to another Python File ???

2011-01-26 Thread bansi
(sys.stdin) os.execv(python_executable, [ python_executable, real_script ] + sys.argv[1:] ) Wondering how would i pass csv reader object r as an argument using os.execv() to another python script i.e. namelookup.py -- http://mail.python.org/mailman/listinfo/python-list

Is it possible to pass CSV Reader Object As Argument to another Python File ??? Options

2011-01-26 Thread Bansilal Haudakari
(sys.stdin) os.execv(python_executable, [ python_executable, real_script ] + sys.argv[1:] ) Wondering how would i pass csv reader object r as an argument using os.execv() to another python script i.e. namelookup.py Regards, Bansi - Bansilal Haudakari

Re: Is it possible to pass CSV Reader Object As Argument to another Python File ???

2011-01-26 Thread Emile van Sebille
\\bin\\namelookup.py r = csv.reader(sys.stdin) os.execv(python_executable, [ python_executable, real_script ] + sys.argv[1:] ) Wondering how would i pass csv reader object r as an argument using os.execv() to another python script i.e. namelookup.py I suspect you're on the wrong path. You

Re: Is it possible to pass CSV Reader Object As Argument to another Python File ???

2011-01-26 Thread bansi
= sys.argv[1] namef = sys.argv[2] real_script = C:\\Splunk\\etc\\apps\\search\\bin\\namelookup.py r = csv.reader(sys.stdin) os.execv(python_executable, [ python_executable, real_script ] + sys.argv[1:] ) Wondering how would i pass csv reader object r as an argument using os.execv

Re: Is it possible to pass CSV Reader Object As Argument to another Python File ???

2011-01-26 Thread Chris Rebert
] real_script = C:\\Splunk\\etc\\apps\\search\\bin\\namelookup.py r = csv.reader(sys.stdin) os.execv(python_executable, [ python_executable, real_script ] + sys.argv[1:] ) Wondering how would i pass csv reader object r as an argument using os.execv() to another python script i.e. namelookup.py It's

Re: Is it possible to pass CSV Reader Object As Argument to another Python File ???

2011-01-26 Thread bansi
code snippet idf = sys.argv[1] namef = sys.argv[2] real_script = C:\\Splunk\\etc\\apps\\search\\bin\\namelookup.py r = csv.reader(sys.stdin) os.execv(python_executable, [ python_executable, real_script ] + sys.argv[1:] ) Wondering how would i pass csv reader object r as an argument

Re: Is it possible to pass CSV Reader Object As Argument to another Python File ???

2011-01-26 Thread Ben Finney
doing the work in a single process, where the CSV reader object can be shared? If thats not possible then please let me know how to do the workaround i didnt understood the import thing and not sure if it helps in my case The problem as you've described it so far is best solved by having a single

Re: Is it possible to pass CSV Reader Object As Argument to another Python File ???

2011-01-26 Thread bansi
structured them that way, though? What constraint is keeping you from doing the work in a single process, where the CSV reader object can be shared? If thats not possible then please let me know how to do the workaround i didnt understood the import thing and not sure if it helps in my case

Re: Is it possible to pass CSV Reader Object As Argument to another Python File ???

2011-01-26 Thread Ethan Furman
bansi wrote: First namelookupWrapper.py running under Python 2.6 accept arguments from stdin and uses csv reader object to read it i.e. r=csv.reader(sys.stdin) And then it has to pass csv reader object to another python script namelookup.py running under Python 2.7 because it uses pyodbc

Re: Is it possible to pass CSV Reader Object As Argument to another Python File ???

2011-01-26 Thread bansi
On Jan 26, 6:25 pm, Ethan Furman et...@stoneleaf.us wrote: bansi wrote:   First namelookupWrapper.py running under Python 2.6 accept arguments   from stdin and uses csv reader object to read it i.e.   r=csv.reader(sys.stdin)     And then it has to pass csv reader object to another python

Re: Is it possible to pass CSV Reader Object As Argument to another Python File ???

2011-01-26 Thread MRAB
On 27/01/2011 00:57, bansi wrote: On Jan 26, 6:25 pm, Ethan Furmanet...@stoneleaf.us wrote: bansi wrote: First namelookupWrapper.py running under Python 2.6 accept arguments from stdin and uses csv reader object to read it i.e. r=csv.reader(sys.stdin) And then it has

[issue7185] csv reader utf-8 BOM error

2010-05-20 Thread Skip Montanaro
Changes by Skip Montanaro s...@pobox.com: -- nosy: -skip.montanaro ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7185 ___ ___ Python-bugs-list

Re: csv reader

2009-12-17 Thread Emmanuel
As csv.reader does not suport utf-8 encoded files, I'm using: fp = codecs.open(arquivoCSV, r, utf-8) self.tab=[] for l in fp: l=l.replace('\','').strip() self.tab.append(l.split(',')) It works much better except that when I do self.sel.type(q, ustring) where ustring is a unicode string

csv reader

2009-12-15 Thread Emmanuel
I have a problem with csv.reader from the library csv. I'm not able to import accentuated caracters. For example, I'm trying to import a simple file containing a single word equação using the following code: import csv arquivoCSV='test' a=csv.reader(open(arquivoCSV),delimiter=',') tab=[] for row

Re: csv reader

2009-12-15 Thread Chris Rebert
On Tue, Dec 15, 2009 at 1:24 PM, Emmanuel manou...@gmail.com wrote: I have a problem with csv.reader from the library csv. I'm not able to import accentuated caracters. For example, I'm trying to import a simple file containing a single word equação using the following code: import csv

Re: csv reader

2009-12-15 Thread Jerry Hill
On Tue, Dec 15, 2009 at 4:24 PM, Emmanuel manou...@gmail.com wrote: I have a problem with csv.reader from the library csv. I'm not able to import accentuated caracters. For example, I'm trying to import a simple file containing a single word equação using the following code: import csv

Re: csv reader

2009-12-15 Thread Emmanuel
Then my problem is diferent! In fact I'm reading a csv file saved from openoffice oocalc using UTF-8 encoding. I get a list of list (let's cal it tab) with the csv data. If I do: print tab[2][4] In ipython, I get: equação de Toricelli. Tarefa exercícios PVR 1 e 2 ; PVP 1 If I only do: tab[2][4]

Re: csv reader

2009-12-15 Thread Gabriel Genellina
En Tue, 15 Dec 2009 19:12:01 -0300, Emmanuel manou...@gmail.com escribió: Then my problem is diferent! In fact I'm reading a csv file saved from openoffice oocalc using UTF-8 encoding. I get a list of list (let's cal it tab) with the csv data. If I do: print tab[2][4] In ipython, I get:

[issue7185] csv reader utf-8 BOM error

2009-10-24 Thread Istvan Szirtes
' ) txt = InDistancesFile.read()[1:] # to leave the BOM lines = txt.splitlines()[1:] # to leave the first row which is a header InDistancesObj = list(csv.reader( lines )) # convert the csv reader object into a simple list Many thanks for your help, Istvan

[issue7185] csv reader utf-8 BOM error

2009-10-22 Thread Istvan Szirtes
row and if I try to seek up to 0 somewhere in the file I got an error like this: ['\ufeffvalue', 'vocal', 'vocal', 'vocal', 'vocal'] I think the csv reader is not seekable correctly. I attached a test file for the bug and here is my code: import codecs import csv InDistancesFile = codecs.open

[issue7185] csv reader utf-8 BOM error

2009-10-22 Thread Walter Dörwald
Walter Dörwald wal...@livinglogic.de added the comment: http://docs.python.org/library/csv.html#module-csv states: This version of the csv module doesn’t support Unicode input. Also, there are currently some issues regarding ASCII NUL characters. Accordingly, all input should be UTF-8 or

[issue7185] csv reader utf-8 BOM error

2009-10-22 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: The restrictions were theoretically removed in 3.1, and the 3.1 documentation has been updated to reflect that. If 3.1 CSV doesn't handle unicode, then that is a bug. -- nosy: +r.david.murray priority: - normal stage: - test

[issue7185] csv reader utf-8 BOM error

2009-10-22 Thread Walter Dörwald
Walter Dörwald wal...@livinglogic.de added the comment: Then the solution should simply be to use utf-8-sig as the encoding, instead of utf-8. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7185

[issue7185] csv reader utf-8 BOM error

2009-10-22 Thread R. David Murray
R. David Murray rdmur...@bitdance.com added the comment: In that case we should update the docs. Istvan, can you confirm that this solves your problem? -- assignee: - georg.brandl components: +Documentation nosy: +georg.brandl stage: test needed - needs patch versions: +Python 3.2

[issue7185] csv reader utf-8 BOM error

2009-10-22 Thread Skip Montanaro
Changes by Skip Montanaro s...@pobox.com: -- nosy: +skip.montanaro ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7185 ___ ___ Python-bugs-list

Re: intermediate python csv reader/writer question from a beginner

2009-02-24 Thread Nick Craig-Wood
Learning Python labm...@gmail.com wrote: anything related to csv, I usually use VB within excel to manipulate the data, nonetheless, i finally got the courage to take a dive into python. i have viewed a lot of googled csv tutorials, but none of them address everything i need.

intermediate python csv reader/writer question from a beginner

2009-02-23 Thread Learning Python
anything related to csv, I usually use VB within excel to manipulate the data, nonetheless, i finally got the courage to take a dive into python. i have viewed a lot of googled csv tutorials, but none of them address everything i need. Nonetheless, I was wondering if someone can help me

Re: intermediate python csv reader/writer question from a beginner

2009-02-23 Thread Chris Rebert
On Mon, Feb 23, 2009 at 1:33 PM, Learning Python labm...@gmail.com wrote: anything related to csv, I usually use VB within excel to manipulate the data, nonetheless, i finally got the courage to take a dive into python. i have viewed a lot of googled csv tutorials, but none of them address

[issue1111100] csv reader barfs encountering quote when quote_none is set

2009-02-19 Thread Daniel Diniz
Changes by Daniel Diniz aja...@gmail.com: -- resolution: - out of date stage: - committed/rejected status: pending - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue100 ___

[issue1111100] csv reader barfs encountering quote when quote_none is set

2009-02-17 Thread Daniel Diniz
Changes by Daniel Diniz aja...@gmail.com: -- priority: normal - low status: open - pending ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue100 ___

[issue1111100] csv reader barfs encountering quote when quote_none is set

2009-02-15 Thread Daniel Diniz
Daniel Diniz aja...@gmail.com added the comment: Cannot reproduce (snippet gives correct output). As many newline handling changes went into csv, I will close unless someone can reproduce the bug. -- nosy: +ajaksu2 type: - behavior ___ Python

CSV reader and unique ids

2008-09-01 Thread Mike P
Hi All, I'm trying to use the CSV module to read in some data and then use a hashable method (as there are millions of records) to find unique ids and push these out to another file, can anyone advise? Below is the code so far fin = open(CSV_INPUT, rb) fout = open(CSV_OUTPUT, wb) reader =

Re: CSV reader and unique ids

2008-09-01 Thread Tim Golden
Mike P wrote: I'm trying to use the CSV module to read in some data and then use a hashable method (as there are millions of records) to find unique ids and push these out to another file, You could either zip with a counter or use the uuid module, depending on just how unique you want your

Re: CSV Reader

2008-02-12 Thread Mike P
import csv reader = csv.reader(open(working_CSV, rb)) writer = csv.writer(open(save_file, wb)) for row in reader: if not start_line and record.startswith('Transaction ID'): start_line=True if start_line: print row writer.writerows(rows) #writer.close() -- http

RE: CSV Reader

2008-02-12 Thread Reedick, Andrew
-Original Message- From: [EMAIL PROTECTED] [mailto:python- [EMAIL PROTECTED] On Behalf Of Mike P Sent: Tuesday, February 12, 2008 5:37 AM To: python-list@python.org Subject: Re: CSV Reader just saw i needed to change record.startswith to row.startswith but i get hte following

Re: CSV Reader

2008-02-12 Thread Gabriel Genellina
, line 310, in RunScript exec codeObject in __main__.__dict__ File Y:\technical\Research\E2C\Template_CSV\import CSV test.py, line 10, in module if not start_line and row.startswith('Transaction ID'): AttributeError: 'list' object has no attribute 'startswith' The csv reader doesn't

Re: CSV Reader

2008-02-12 Thread Mike P
Hi Chris that's exactley what i wanted to do, Many thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: CSV Reader

2008-02-12 Thread Mike P
I was just trying to do it with the CSV module -- http://mail.python.org/mailman/listinfo/python-list

Re: CSV Reader

2008-02-12 Thread Chris
/technical/Research/E2C/Template_CSV/ CSV_Data2.csv start_line=False import csv reader = csv.reader(open(working_CSV, rb)) writer = csv.writer(open(save_file, wb)) for row in reader: if not start_line and record.startswith('Transaction ID'): start_line=True if start_line: print

Re: CSV Reader

2008-02-12 Thread Mike P
just saw i needed to change record.startswith to row.startswith but i get hte following traceback error Traceback (most recent call last): File C:\Python25\Lib\site-packages\pythonwin\pywin\framework \scriptutils.py, line 310, in RunScript exec codeObject in __main__.__dict__ File

Re: CSV Reader

2008-02-11 Thread Gabriel Genellina
En Mon, 11 Feb 2008 14:41:54 -0200, Mike P [EMAIL PROTECTED] escribi�: CSV_Data = open(working_CSV) data = CSV_Data.readlines() flag=False for record in data: if record.startswith('Transaction ID'): [...] Files are already iterable by lines. There is no need to use readlines(),

RE: CSV Reader

2008-02-11 Thread Reedick, Andrew
-Original Message- From: [EMAIL PROTECTED] [mailto:python- [EMAIL PROTECTED] On Behalf Of Mike P Sent: Monday, February 11, 2008 11:42 AM To: python-list@python.org Subject: Re: CSV Reader Cheers for the help, the second way looked to be the best in the end, and thanks

Re: CSV Reader

2008-02-11 Thread Mike P
Cheers for the help, the second way looked to be the best in the end, and thanks for the boolean idea Mike working_CSV = //filer/common/technical/Research/E2C/Template_CSV/ DFAExposureToConversionQueryTool.csv save_file = open(//filer/common/technical/Research/E2C/Template_CSV/

  1   2   >