Re: Reading binary data with the CSV module

2020-11-30 Thread MRAB
On 2020-11-30 03:59, Jason Friedman wrote: csv.DictReader appears to be happy with a list of strings representing the lines. Try this: contents = source_file.content() for row in csv.DictReader(contents.decode('utf-8').splitlines()): print(row) Works great, thank you! Question ... wil

Re: Reading binary data with the CSV module

2020-11-29 Thread Jason Friedman
> > csv.DictReader appears to be happy with a list of strings representing > the lines. > > Try this: > > contents = source_file.content() > > for row in csv.DictReader(contents.decode('utf-8').splitlines()): > print(row) > Works great, thank you! Question ... will this form potentially use l

Re: Reading binary data with the CSV module

2020-11-29 Thread MRAB
On 2020-11-30 01:31, Jason Friedman wrote: Using the Box API: print(source_file.content()) returns b'First Name,Last Name,Email Address,Company,Position,Connected On\nPeter,van (and more data, not pasted here) Trying to read it via: with io.TextIOWrapper(source_file.content(), encoding=

Reading binary data with the CSV module

2020-11-29 Thread Jason Friedman
Using the Box API: print(source_file.content()) returns b'First Name,Last Name,Email Address,Company,Position,Connected On\nPeter,van (and more data, not pasted here) Trying to read it via: with io.TextIOWrapper(source_file.content(), encoding='utf-8') as text_file: reader = csv.DictRead

Re: i am want to read data from the csv that i wrote using python csv module but apart from filed names and row count i am unable to read rest of the data

2020-04-15 Thread sjeik_appie
On 15 Apr 2020 10:28, Peter Otten <__pete...@web.de> wrote: sjeik_ap...@hotmail.com wrote: >    On 12 Apr 2020 12:30, Peter Otten <__pete...@web.de> wrote: > >  Rahul Gupta wrote: > >  >for line in enumerate(csv_reader): >  >print(line[csv_reader.

Re: i am want to read data from the csv that i wrote using python csv module but apart from filed names and row count i am unable to read rest of the data

2020-04-15 Thread Peter Otten
sjeik_ap...@hotmail.com wrote: >On 12 Apr 2020 12:30, Peter Otten <__pete...@web.de> wrote: > > Rahul Gupta wrote: > > >for line in enumerate(csv_reader): > >print(line[csv_reader.fieldnames[1]]) > > enumerate() generates (index, line) tuples that you need to unpack: >

Re: i am want to read data from the csv that i wrote using python csv module but apart from filed names and row count i am unable to read rest of the data

2020-04-14 Thread sjeik_appie
On 12 Apr 2020 12:30, Peter Otten <__pete...@web.de> wrote: Rahul Gupta wrote: > for line in enumerate(csv_reader): > print(line[csv_reader.fieldnames[1]]) enumerate() generates (index, line) tuples that you need to unpack:     for index, line in enumerat

Re: i am want to read data from the csv that i wrote using python csv module but apart from filed names and row count i am unable to read rest of the data

2020-04-12 Thread Rahul Gupta
@Peter Thanks alot -- https://mail.python.org/mailman/listinfo/python-list

Re: i am want to read data from the csv that i wrote using python csv module but apart from filed names and row count i am unable to read rest of the data

2020-04-12 Thread Peter Otten
Rahul Gupta wrote: > for line in enumerate(csv_reader): > print(line[csv_reader.fieldnames[1]]) enumerate() generates (index, line) tuples that you need to unpack: for index, line in enumerate(csv_reader): print(line[csv_reader.fieldnames[1]]) If you want to keep track o

Re: i am want to read data from the csv that i wrote using python csv module but apart from filed names and row count i am unable to read rest of the data

2020-04-12 Thread Rahul Gupta
import csv import numpy as np with open("D:\PHD\obranking\\cell_split_demo.csv", mode='r') as csv_file: csv_reader = csv.DictReader(csv_file) print(csv_reader.fieldnames) col_count = print(len(csv_reader.fieldnames)) #print(sum(1 for row in csv_file)) row_count = 0

Re: i am want to read data from the csv that i wrote using python csv module but apart from filed names and row count i am unable to read rest of the data

2020-04-12 Thread Peter Otten
Rahul Gupta wrote: > On Sunday, April 12, 2020 at 1:35:10 PM UTC+5:30, Rahul Gupta wrote: >> the cells in my csv that i wrote looks likes this >> ['82#201#426#553#602#621#811#908#1289#1342#1401#1472#1593#1641#1794#2290#2341#2391#3023#3141#3227#3240#3525#3529#3690#3881#4406#4421#4497#4719#4722#492

Re: i am want to read data from the csv that i wrote using python csv module but apart from filed names and row count i am unable to read rest of the data

2020-04-12 Thread Rahul Gupta
On Sunday, April 12, 2020 at 1:35:10 PM UTC+5:30, Rahul Gupta wrote: > the cells in my csv that i wrote looks likes this > ['82#201#426#553#602#621#811#908#1289#1342#1401#1472#1593#1641#1794#2290#2341#2391#3023#3141#3227#3240#3525#3529#3690#3881#4406#4421#4497#4719#4722#4920#5053#5146#5433'] > and

Re: i am want to read data from the csv that i wrote using python csv module but apart from filed names and row count i am unable to read rest of the data

2020-04-12 Thread Peter Otten
Rahul Gupta wrote: > the cells in my csv that i wrote looks likes this > ['82#201#426#553#602#621#811#908#1289#1342#1401#1472#1593#1641#1794#2290#2341#2391#3023#3141#3227#3240#3525#3529#3690#3881#4406#4421#4497#4719#4722#4920#5053#5146#5433'] > and the cells which are empty looks like [''] i have

i am want to read data from the csv that i wrote using python csv module but apart from filed names and row count i am unable to read rest of the data

2020-04-12 Thread Rahul Gupta
the cells in my csv that i wrote looks likes this ['82#201#426#553#602#621#811#908#1289#1342#1401#1472#1593#1641#1794#2290#2341#2391#3023#3141#3227#3240#3525#3529#3690#3881#4406#4421#4497#4719#4722#4920#5053#5146#5433'] and the cells which are empty looks like [''] i have tried the following code

Re: csv module and NULL data byte

2018-03-11 Thread Andrew McNamara
>Any idea why it might throw an exception on encountering a NULL in the >input stream? It accepts all other 255 byte values. Was this behaviour >intended? Perhaps a comment should be added to the docs. >Thanks for your work on the module anyway. The original module was like this - it comes about

Re: csv module and NULL data byte

2018-03-07 Thread John Pote
n the rationale behind the binary recommendation, but in 10+ years of using the csv module, I've not found any issues in using text/ascii mode that were solved by switching to using binary mode. The CSV module was originally written by Dave Cole. I subsequently made changes necessary to get it incl

Re: csv module and NULL data byte

2018-03-07 Thread Andrew McNamara
nd the binary recommendation, but in 10+ years of using >the csv module, I've not found any issues in using text/ascii mode >that were solved by switching to using binary mode. The CSV module was originally written by Dave Cole. I subsequently made changes necessary to get it included

Re: csv module and NULL data byte

2018-03-01 Thread Tim Chase
On 2018-03-01 23:57, John Pote wrote: > On 01/03/2018 01:35, Tim Chase wrote: > > While inelegant, I've "solved" this with a wrapper/generator > > > >f = file(fname, …) > >g = (line.replace('\0', '') for line in f) > I wondered about something like this but thought if there's a way > of a

Re: csv module and NULL data byte

2018-03-01 Thread John Pote
On 01/03/2018 01:35, Tim Chase wrote: While inelegant, I've "solved" this with a wrapper/generator f = file(fname, …) g = (line.replace('\0', '') for line in f) I wondered about something like this but thought if there's a way of avoiding the extra step it would keep the execution speed u

Re: csv module and NULL data byte

2018-03-01 Thread John Pote
On 01/03/2018 02:38, Dennis Lee Bieber wrote: On Wed, 28 Feb 2018 23:40:41 +, John Pote declaimed the following:     with open( fname, 'rt', encoding='iso-8859-1' ) as csvfile: Pardon? Has the CSV module changed in the last year or so? Python 3.6 docs say

Re: csv module and NULL data byte

2018-03-01 Thread Neil Cerutti
On 2018-03-01, Tim Chase wrote: > On 2018-02-28 21:38, Dennis Lee Bieber wrote: >> >     with open( fname, 'rt', encoding='iso-8859-1' ) as csvfile: >> >> Pardon? Has the CSV module changed in the last year or so? >> >> Las

Re: csv module and NULL data byte

2018-02-28 Thread Terry Reedy
On 2/28/2018 8:35 PM, Tim Chase wrote: While inelegant, I've "solved" this with a wrapper/generator f = file(fname, …) g = (line.replace('\0', '') for line in f) reader = csv.reader(g, …) for row in reader: process(row) I think this is elegant in that is cleans the input strea

Re: csv module and NULL data byte

2018-02-28 Thread Tim Chase
On 2018-02-28 21:38, Dennis Lee Bieber wrote: > >     with open( fname, 'rt', encoding='iso-8859-1' ) as csvfile: > > Pardon? Has the CSV module changed in the last year or so? > > Last time I read the documentation, it was recommended that &g

Re: csv module and NULL data byte

2018-02-28 Thread Tim Chase
While inelegant, I've "solved" this with a wrapper/generator f = file(fname, …) g = (line.replace('\0', '') for line in f) reader = csv.reader(g, …) for row in reader: process(row) My actual use at $DAYJOB cleans out a few other things too, particularly non-breaking spaces coming from

csv module and NULL data byte

2018-02-28 Thread John Pote
I have a csv data file that may become corrupted (already happened) resulting in a NULL byte appearing in the file. The NULL byte causes an _csv.Error exception. I'd rather like the csv reader to return csv lines as best it can and subsequent processing of each comma separated field deal with

Re: issue with csv module (subject module name spelling correction, too)

2016-03-11 Thread Martin A. Brown
dialect control, I'd be a touch surprised, but, it is possible that your other csv readers and writers are more finicky. Did you see the parameters that are available to you for tuning how the csv module turns your csv data into records? https://docs.python.org/3/library/csv.html#dialects-

Re: Number of cells, using CSV module

2013-05-16 Thread tunacubes
Thank you Skip, worked great. And thank you Tim for Tidying things up! -- http://mail.python.org/mailman/listinfo/python-list

Re: Number of cells, using CSV module

2013-05-16 Thread Tim Chase
On 2013-05-16 14:08, Skip Montanaro wrote: > > So rather than > >>a > >>b > >>c > >>d > >>e > >>f > > I would get [a, b, c, d, e, f] > > all_items = [] > for row in reader: > all_items.append(row[0]) And following up here, this could be tidily rewritten as all_items = [row[0] for row in re

Re: Number of cells, using CSV module

2013-05-16 Thread Tim Chase
On 2013-05-16 14:07, Skip Montanaro wrote: > > len(reader) gives me an error. > > Apologies. len(list(reader)) should work. Of course, you'll wind > up loading the entire CSV file into memory. You might want to just > count row-by-row: > > n = 0 > for row in reader: > n += 1 which can nic

Re: Number of cells, using CSV module

2013-05-16 Thread Skip Montanaro
> So rather than >>a >>b >>c >>d >>e >>f > I would get [a, b, c, d, e, f] all_items = [] for row in reader: all_items.append(row[0]) Skip -- http://mail.python.org/mailman/listinfo/python-list

Re: Number of cells, using CSV module

2013-05-16 Thread Skip Montanaro
> len(reader) gives me an error. Apologies. len(list(reader)) should work. Of course, you'll wind up loading the entire CSV file into memory. You might want to just count row-by-row: n = 0 for row in reader: n += 1 Skip -- http://mail.python.org/mailman/listinfo/python-list

Re: Number of cells, using CSV module

2013-05-16 Thread tunacubes
I guess another way to accomplish this would be, is there any way that I can turn the returned value for (column) into 1 list? So rather than >a >b >c >d >e >f I would get [a, b, c, d, e, f] -- http://mail.python.org/mailman/listinfo/python-list

Re: Number of cells, using CSV module

2013-05-16 Thread tunacubes
On Thursday, May 16, 2013 2:40:08 PM UTC-4, Skip Montanaro wrote: > Perhaps you want len(reader) instead?  Or a counter which increments for > every row read which has an item in column A? > > > > Skip len(reader) gives me an error. I tried a counter, but unfortunately due to the simplicity

Re: Number of cells, using CSV module

2013-05-16 Thread Skip Montanaro
Perhaps you want len(reader) instead? Or a counter which increments for every row read which has an item in column A? Skip -- http://mail.python.org/mailman/listinfo/python-list

Number of cells, using CSV module

2013-05-16 Thread tunacubes
I'm using the csv module to get information from a csv file. I have items listed in Column A. I want to know how many items are listed in Column A. import csv with open('test.csv', 'r') as f: reader = csv.reader(f) for column in reader: column = (column

Re: working with csv module in python

2013-02-20 Thread inshu chauhan
On Wed, Feb 20, 2013 at 12:04 PM, Dave Angel wrote: > On 02/20/2013 05:38 AM, inshu chauhan wrote: > >> On Wed, Feb 20, 2013 at 11:26 AM, Roland Koebler >> wrote: >> >> >>> >>> >>> >>> If you only want to concat the files, I would use some shell-tools, >>> like "cat" on Linux or "copy" on Windo

Re: working with csv module in python

2013-02-20 Thread Dave Angel
On 02/20/2013 06:01 AM, inshu chauhan wrote: For simple concating the files , I tried the following code : import glob with open(r"C:\Users\inshu.chauhan\Desktop\test2.arff", "w") as w: print w for f in glob.glob(r"C:\Users\inshu.chauhan\Desktop\For Model_600\*.arff"): You fo

Re: working with csv module in python

2013-02-20 Thread Dave Angel
On 02/20/2013 05:38 AM, inshu chauhan wrote: On Wed, Feb 20, 2013 at 11:26 AM, Roland Koebler wrote: If you only want to concat the files, I would use some shell-tools, like "cat" on Linux or "copy" on Windows, so copy C:\Users\inshu.chauhan\Desktop\ForModel_600\*.arff C:\Users\inshu.chauh

Re: working with csv module in python

2013-02-20 Thread inshu chauhan
in >> > reading and there is space between every row too.. >> Because there's a "split()" missing in your code. You currently tell the >> CSV-writer to write the columns 2,9,9, , , ,4,4,6, , , ,2 as >> space-separated CSV. So, try something like >>

Re: working with csv module in python

2013-02-20 Thread Peter Otten
inshu chauhan wrote: > Yes I just want to concat the files , not parse/mangle the files. How > can > i simply read all files in a folder in my computer and write them into a > single file ? just by 'printf ' is it possible ? Assuming the files' last line always ends with a newline and the files

Re: working with csv module in python

2013-02-20 Thread inshu chauhan
e the columns 2,9,9, , , ,4,4,6, , , ,2 as > space-separated CSV. So, try something like > rows = [r.split() for r in open(f, "r").readlines()] > > > Or can I merge these text files without using csv module , directly in > > python ? > If you don't need to pars

Re: working with csv module in python

2013-02-20 Thread Roland Koebler
ecause there's a "split()" missing in your code. You currently tell the CSV-writer to write the columns 2,9,9, , , ,4,4,6, , , ,2 as space-separated CSV. So, try something like rows = [r.split() for r in open(f, "r").readlines()] > Or can I merge these text files without usi

working with csv module in python

2013-02-20 Thread inshu chauhan
nt why there is space between the attribute of first column in reading and there is space between every row too.. Or can I merge these text files without using csv module , directly in python ? Looking forward to your suggestions. Thanks in advance !!! -- http://mail.python.org/mailman/listinfo/python-list

Re: extra rows in a CSV module output when viewed in excel 2007

2010-08-19 Thread JonathanB
On Aug 20, 9:10 am, MRAB wrote: > JonathanB wrote: > > On Aug 13, 3:52 pm, alex23 wrote: > >> On Aug 13, 4:22 pm, JonathanB wrote: > > >>>         writer = csv.writer(open(output, 'w'), dialect='excel') > >> I think - not able to test atm - that if you open the file in 'wb' > >> mode instead it

Re: extra rows in a CSV module output when viewed in excel 2007

2010-08-19 Thread MRAB
JonathanB wrote: On Aug 13, 3:52 pm, alex23 wrote: On Aug 13, 4:22 pm, JonathanB wrote: writer = csv.writer(open(output, 'w'), dialect='excel') I think - not able to test atm - that if you open the file in 'wb' mode instead it should be fine. changed that to writer = csv.writer(op

Re: extra rows in a CSV module output when viewed in excel 2007

2010-08-19 Thread JonathanB
On Aug 13, 3:52 pm, alex23 wrote: > On Aug 13, 4:22 pm, JonathanB wrote: > > >         writer = csv.writer(open(output, 'w'), dialect='excel') > > I think - not able to test atm - that if you open the file in 'wb' > mode instead it should be fine. changed that to writer = csv.writer(open(output,

Re: extra rows in a CSV module output when viewed in excel 2007

2010-08-12 Thread alex23
On Aug 13, 4:22 pm, JonathanB wrote: >         writer = csv.writer(open(output, 'w'), dialect='excel') I think - not able to test atm - that if you open the file in 'wb' mode instead it should be fine. -- http://mail.python.org/mailman/listinfo/python-list

extra rows in a CSV module output when viewed in excel 2007

2010-08-12 Thread JonathanB
The subject basically says it all, here's the code that's producing the csv file: def write2CSV(self,output): writer = csv.writer(open(output, 'w'), dialect='excel') writer.writerow(['Name','Description','Due Date','Subject', 'Grade','Maximum Grade', se

Re: escape character / csv module

2010-07-02 Thread John Machin
On Jul 2, 6:04 am, MRAB wrote: > The csv module imports from _csv, which suggests to me that there's code > written in C which thinks that the "\x00" is a NUL terminator, so it's a > bug, although it's very unusual to want to write characters like "\

Re: escape character / csv module

2010-07-01 Thread MRAB
V N wrote: string "\x00" has a length of 1. When I use the csv module to write that to a file csv_f = csv.writer(file("test.csv","wb"),delimiter="|") csv_f.writerow(["\x00","zz"]) The output file looks like this: |zz Is it possi

Re: escape character / csv module

2010-07-01 Thread anon
V N wrote: string "\x00" has a length of 1. When I use the csv module to write that to a file csv_f = csv.writer(file("test.csv","wb"),delimiter="|") csv_f.writerow(["\x00","zz"]) The output file looks like this: |zz Is it possi

escape character / csv module

2010-07-01 Thread V N
string "\x00" has a length of 1. When I use the csv module to write that to a file csv_f = csv.writer(file("test.csv","wb"),delimiter="|") csv_f.writerow(["\x00","zz"]) The output file looks like this: |zz Is it possible to force

Re: problems with CSV module

2010-06-05 Thread Tim Roberts
Carlos Grohmann wrote: > >Hi all, I'm using csv to read text files, and its working fine, except >in two cases: > >- when there is only one line of text (data) in the file >- when there is a blank line after the last data line >dialect = csv.Sniffer().sniff(sample) # Check for file format wit

Re: problems with CSV module

2010-06-03 Thread Neil Cerutti
On 2010-06-03, Carlos Grohmann wrote: >> Use: >> ? ?csvfile = csv.reader(csvfile, dialect=dialect) >> dialect is a keyword argument. > > thanks for pointing that out.it stopped the errors when there s > only one data line, but it still can't get the values for that > line Is it possible your data

Re: problems with CSV module

2010-06-03 Thread Carlos Grohmann
Thanks for your prompt response, Neil. > That data doesn't appear to be csv worthy. Why not use str.split > or str.partition? Well, I should have said that this is one kind of data. The function is part of a larger app, and there is the possibility that someone uses headers in the data files, or

Re: problems with CSV module

2010-06-03 Thread Neil Cerutti
On 2010-06-03, Neil Cerutti wrote: > Do you really need to use the Sniffer? You'll probably be better > off... ...defining your own dialect based on what you know to be the file format. -- Neil Cerutti -- http://mail.python.org/mailman/listinfo/python-list

Re: problems with CSV module

2010-06-03 Thread Neil Cerutti
On 2010-06-03, Carlos Grohmann wrote: > Hi all, I'm using csv to read text files, and its working fine, except > in two cases: > > - when there is only one line of text (data) in the file > - when there is a blank line after the last data line > > this is the kind of data: > > 45 67 89 > 23 45 06

problems with CSV module

2010-06-03 Thread Carlos Grohmann
Hi all, I'm using csv to read text files, and its working fine, except in two cases: - when there is only one line of text (data) in the file - when there is a blank line after the last data line this is the kind of data: 45 67 89 23 45 06 12 34 67 ... and this is the function: def getData(pa

Re: comparing dialects of csv-module

2009-12-20 Thread Malte Dik
quote: d = csv.Sniffer().sniff("1,2,3") def eq(a, b, attributes=[name for name in dir(d) if not > name.startswith("_")]): > ... return all(getattr(a, n, None) == getattr(b, n, None) for n in > attributes) Only change I made is substituting "dir(csv.excel)" or "dir(csv.Dialect)" for

Re: comparing dialects of csv-module

2009-12-19 Thread Malte Dik
quote: > An implementation for the lazy > import csv d = csv.Sniffer().sniff("1,2,3") def eq(a, b, attributes=[name for name in dir(d) if not > name.startswith("_")]): > ... return all(getattr(a, n, None) == getattr(b, n, None) for n in > attributes) > ... Wow, this is awesome.

Re: comparing dialects of csv-module

2009-12-19 Thread Peter Otten
Malte Dik wrote: > Hi out there! > > I want to put some intelligence into a csv reading script and in order to > do so I want to compare possible different dialects I collect with some > random > > d = csv.Sniffer().sniff("1,2,3,4"), > > because the csv is kinda dirty. > > Now sniff() returns

comparing dialects of csv-module

2009-12-19 Thread Malte Dik
Hi out there! I want to put some intelligence into a csv reading script and in order to do so I want to compare possible different dialects I collect with some random d = csv.Sniffer().sniff("1,2,3,4"), because the csv is kinda dirty. Now sniff() returns a class object and those aren't compara

Re: csv module and None values

2009-08-29 Thread JKPeck
On Aug 25, 8:49 am, Peter Otten <__pete...@web.de> wrote: > JKPeck wrote: > > On Aug 24, 10:43 pm, John Yeung wrote: > >> On Aug 24, 5:00 pm, Peter Otten <__pete...@web.de> wrote: > > >> > If I understand you correctly the csv.writer already does > >> > what you want: > > >> > >>> w.writerow([1,No

Re: csv module and None values

2009-08-25 Thread Peter Otten
JKPeck wrote: > On Aug 24, 10:43 pm, John Yeung wrote: >> On Aug 24, 5:00 pm, Peter Otten <__pete...@web.de> wrote: >> >> > If I understand you correctly the csv.writer already does >> > what you want: >> >> > >>> w.writerow([1,None,2]) >> > 1,,2 >> >> > just sequential commas, but that is the sp

Re: csv module and None values

2009-08-25 Thread JKPeck
On Aug 24, 10:43 pm, John Yeung wrote: > On Aug 24, 5:00 pm, Peter Otten <__pete...@web.de> wrote: > > > If I understand you correctly the csv.writer already does > > what you want: > > > >>> w.writerow([1,None,2]) > > 1,,2 > > > just sequential commas, but that is the special treatment. > > Witho

Re: csv module and None values

2009-08-24 Thread John Yeung
On Aug 24, 5:00 pm, Peter Otten <__pete...@web.de> wrote: > If I understand you correctly the csv.writer already does > what you want: > > >>> w.writerow([1,None,2]) > 1,,2 > > just sequential commas, but that is the special treatment. > Without it the None value would be converted to a string > an

Re: csv module and None values

2009-08-24 Thread John Yeung
On Aug 24, 1:30 pm, JKPeck wrote: > I'm trying to get the csv module (Python 2.6) to write data > records like Excel.  The excel dialect isn't doing it.  The > problem is in writing None values.  I want them to result > in just sequential commas - ,, but csv treats None s

Re: csv module and None values

2009-08-24 Thread Peter Otten
JKPeck wrote: > I'm trying to get the csv module (Python 2.6) to write data records > like Excel. The excel dialect isn't doing it. The problem is in > writing None values. I want them to result in just sequential commas > - ,, but csv treats None specially, as the doc

Re: csv module and None values

2009-08-24 Thread JKPeck
On Aug 24, 11:30 am, JKPeck wrote: > I'm trying to get the csv module (Python 2.6) to write data records > like Excel.  The excel dialect isn't doing it.  The problem is in > writing None values.  I want them to result in just sequential commas > - ,, but csv treats None

csv module and None values

2009-08-24 Thread JKPeck
I'm trying to get the csv module (Python 2.6) to write data records like Excel. The excel dialect isn't doing it. The problem is in writing None values. I want them to result in just sequential commas - ,, but csv treats None specially, as the doc says, "To make it as easy

Re: Source code for csv module

2009-02-03 Thread Jon Clements
On 3 Feb, 04:27, Tim Roberts wrote: > vsoler wrote: > > >I'm still interested in learning python techniques. Are there any > >other modules (standard or complementary) that I can use in my > >education? > > Are you serious about this?  Are you not aware that virtually ALL of the > Python standard

Re: Source code for csv module

2009-02-02 Thread Tim Roberts
vsoler wrote: > >I'm still interested in learning python techniques. Are there any >other modules (standard or complementary) that I can use in my >education? Are you serious about this? Are you not aware that virtually ALL of the Python standard modules are written in Python, and are included i

Re: Source code for csv module

2009-02-02 Thread vsoler
On 2 feb, 21:51, Jon Clements wrote: > On 2 Feb, 20:46, vsoler wrote: > > > Hi you all, > > > I just discovered the csv module here in the comp.lang.python group. > > > I have found its manual, which is publicly available, but since I am > > still a newby, lea

Re: Source code for csv module

2009-02-02 Thread Tim Chase
I just discovered the csv module here in the comp.lang.python group. It certainly makes life easier. I have found its manual, which is publicly available, but since I am still a newby, learning techniques, I was wondering if the source code for this module is available. Is it possible to

Re: Source code for csv module

2009-02-02 Thread Jon Clements
On 2 Feb, 20:46, vsoler wrote: > Hi you all, > > I just discovered the csv module here in the comp.lang.python group. > > I have found its manual, which is publicly available, but since I am > still a newby, learning techniques, I was wondering if the source code > for thi

Source code for csv module

2009-02-02 Thread vsoler
Hi you all, I just discovered the csv module here in the comp.lang.python group. I have found its manual, which is publicly available, but since I am still a newby, learning techniques, I was wondering if the source code for this module is available. Is it possible to have a look at it? Thanks

Re: CSV module: incorrectly parsed file.

2008-02-17 Thread Steve Holden
>>> 1,"wer","tape 2"",5 >>> 1,vvv,"hoohaa",2 >>> I want to convert it to tab-separated without those silly quotes. Note >>> in the second line that a field is 'tape 2"' , ie two inches: there is >>> a double

Re: CSV module: incorrectly parsed file.

2008-02-17 Thread 7stud
2"",5 > > 1,vvv,"hoohaa",2 > > > I want to convert it to tab-separated without those silly quotes. Note > > in the second line that a field is 'tape 2"' , ie two inches: there is > > a double quote in the string. > > > When I us

Re: CSV module: incorrectly parsed file.

2008-02-17 Thread 7stud
those silly quotes. Note > in the second line that a field is 'tape 2"' , ie two inches: there is > a double quote in the string. > > When I use csv module to read this: > > import sys > outf=open(sys.argv[1]+'.tsv','wt') > import csv > r

Re: CSV module: incorrectly parsed file.

2008-02-17 Thread Paul McGuire
On Feb 17, 8:09 pm, Christopher Barrington-Leigh <[EMAIL PROTECTED]> wrote: > Here is a file "test.csv" > number,name,description,value > 1,"wer","tape 2"",5 > 1,vvv,"hoohaa",2 > > I want to convert it to tab-separated without those silly quotes. Note > in the second line that a field is 'tape 2"'

Re: CSV module: incorrectly parsed file.

2008-02-17 Thread Andrew McNamara
>Here is a file "test.csv" >number,name,description,value >1,"wer","tape 2"",5 >1,vvv,"hoohaa",2 > >I want to convert it to tab-separated without those silly quotes. Note >in the second line that a field is 'tape 2"' , ie two inches: there is >a double quote in the string. The input format is ambi

CSV module: incorrectly parsed file.

2008-02-17 Thread Christopher Barrington-Leigh
Here is a file "test.csv" number,name,description,value 1,"wer","tape 2"",5 1,vvv,"hoohaa",2 I want to convert it to tab-separated without those silly quotes. Note in the second line that a field is 'tape 2"' , ie two inches: there is

Re: Strange Behavior: csv module & IDLE

2007-12-28 Thread t_rectenwald
On Dec 28, 9:43 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Dec 29, 1:12 pm, t_rectenwald <[EMAIL PROTECTED]> wrote: > > > I've noticed an oddity when running a program, using the csv module, > > within IDLE.  I'm new to Python so am confused by what

Re: Strange Behavior: csv module & IDLE

2007-12-28 Thread John Machin
On Dec 29, 1:12 pm, t_rectenwald <[EMAIL PROTECTED]> wrote: > I've noticed an oddity when running a program, using the csv module, > within IDLE. I'm new to Python so am confused by what is happening. > Here is what I'm doing: > > 1) Open the IDLE Shell. >

Re: Strange Behavior: csv module & IDLE

2007-12-28 Thread Marc 'BlackJack' Rintsch
On Fri, 28 Dec 2007 18:12:58 -0800, t_rectenwald wrote: > Within the program, the snippet where I use the csv module is below: > > == > csvfile = open('foo.csv', 'w') > writer = csv.writer(csvfile) > > for r

Strange Behavior: csv module & IDLE

2007-12-28 Thread t_rectenwald
I've noticed an oddity when running a program, using the csv module, within IDLE. I'm new to Python so am confused by what is happening. Here is what I'm doing: 1) Open the IDLE Shell. 2) Select File | Open... 3) Choose my file, foo.py, opening it in a window. 4) From that wind

Re: Is anyone happy with csv module?

2007-12-14 Thread Cliff Wells
On Wed, 2007-12-12 at 07:04 -0800, massimo s. wrote: > If by "thoroughly" you mean "it actually describes technically what it > is and does but not how to really do things", yes, it is thoroughly > documented. > The examples section is a joke. Actually I rare

Re: Is anyone happy with csv module?

2007-12-13 Thread Neil Cerutti
On 2007-12-12, John Machin <[EMAIL PROTECTED]> wrote: > On Dec 13, 12:58 am, Neil Cerutti <[EMAIL PROTECTED]> wrote: >> On 2007-12-12, John Machin <[EMAIL PROTECTED]> wrote: >> >> >> It's clear that I am thinking to completely different usages >> >> for CSV than what most people in this thread. I u

Re: Is anyone happy with csv module?

2007-12-12 Thread John Machin
On Dec 13, 12:58 am, Neil Cerutti <[EMAIL PROTECTED]> wrote: > On 2007-12-12, John Machin <[EMAIL PROTECTED]> wrote: > > >> It's clear that I am thinking to completely different usages > >> for CSV than what most people in this thread. I use csv to > >> export and import numerical data columns to a

Re: Is anyone happy with csv module?

2007-12-12 Thread J. Clifford Dyer
On Wed, Dec 12, 2007 at 11:02:04AM -0600, [EMAIL PROTECTED] wrote regarding Re: Is anyone happy with csv module?: > > J. Clifford Dyer <[EMAIL PROTECTED]> wrote: > > But the software you are dealing with probably doesn't actually > > need spreadsheets. It just need

Re: Is anyone happy with csv module?

2007-12-12 Thread Neil Cerutti
When I have a choice, I use simple tab-delimited text files. The >> usually irrelevent limitation is the inability to embed tabs or >> newlines in fields. The relevant advantage is the simplicity. >> > > That is very unnecessary. You can have your tabs and not eat them,

Re: Is anyone happy with csv module?

2007-12-12 Thread Shane Geiger
tabs or > newlines in fields. The relevant advantage is the simplicity. > That is very unnecessary. You can have your tabs and not eat them, too: #!/usr/bin/python """ EXAMPLE USAGE OF PYTHON'S CSV.DICTREADER FOR PEOPLE NEW TO PYTHON AND/OR CSV.DICTREADER Python - Ba

Re: Is anyone happy with csv module?

2007-12-12 Thread J. Clifford Dyer
On Wed, Dec 12, 2007 at 10:08:38AM -0600, [EMAIL PROTECTED] wrote regarding Re: Is anyone happy with csv module?: > > FWIW, CSV is a much more generic format for spreadsheets than XLS. > For example, I deal almost exclusively in CSV files for simialr situations > as the OP because

Re: Is anyone happy with csv module?

2007-12-12 Thread Neil Cerutti
On 2007-12-12, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > John Machin <[EMAIL PROTECTED]> wrote: >> For that purpose, CSV files are the utter pox and then some. >> Consider using xlrd and xlwt (nee pyexcelerator) to read >> (resp. write) XLS files directly. > > FWIW, CSV is a much more generic

Re: Is anyone happy with csv module?

2007-12-12 Thread Marco Mariani
massimo s. wrote: > As for people advicing xlrd/xlrwt: thanks for the useful tip, I didn't > know about it and looks cool, but in this case no way I'm throwing > another dependency to the poor users of my software. Csv module was > good because was built-in. The trouble wit

Re: Is anyone happy with csv module?

2007-12-12 Thread Marco Mariani
John Machin wrote: > For that purpose, CSV files are the utter pox and then some. Consider > using xlrd and xlwt (nee pyexcelerator) to read (resp. write) XLS > files directly. xlwt is unreleased (though quite stable, they say) at the moment, so the links are: easy_install xlrd svn co https://s

Re: Is anyone happy with csv module?

2007-12-12 Thread massimo s.
On Dec 12, 2:58 pm, Neil Cerutti <[EMAIL PROTECTED]> wrote: > On 2007-12-11, massimo s. <[EMAIL PROTECTED]> wrote: > > > Hi, > > > I'm struggling to use the python in-built csv module, and I > > must say I'm less than satisfied. Apart from being r

Re: Is anyone happy with csv module?

2007-12-12 Thread Neil Cerutti
On 2007-12-12, John Machin <[EMAIL PROTECTED]> wrote: >> It's clear that I am thinking to completely different usages >> for CSV than what most people in this thread. I use csv to >> export and import numerical data columns to and from >> spreadsheets. > > For that purpose, CSV files are the utter

Re: Is anyone happy with csv module?

2007-12-12 Thread Neil Cerutti
On 2007-12-11, massimo s. <[EMAIL PROTECTED]> wrote: > Hi, > > I'm struggling to use the python in-built csv module, and I > must say I'm less than satisfied. Apart from being rather > poorly documented, I find it especially cumbersome to use, and > also rather li

Re: Is anyone happy with csv module?

2007-12-12 Thread massimo s.
29 am, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > > I'm just trying to use the CSV module > > and I mostly can get it working. I just think its interface is much > > less than perfect. I'd like something I can, say, give a whole > > dictionary in input a

  1   2   3   >