On 2014-02-06 18:34, Neil Cerutti wrote:
> They do actually mention it.
>
> From: http://docs.python.org/2/library/csv.html
>
> If csvfile is a file object, it must be opened with
> the ‘b’ flag on platforms where that makes a difference.
>
> So it's stipulated only for file objects on syst
[first, it looks like you're posting via Google Groups which
annoyingly double-spaces everything in your reply. It's possible to
work around this, but you might want to subscribe via email or an
actual newsgroup client. You can read more at
https://wiki.python.org/moin/GoogleGroupsPython ]
On 201
On 2014-02-06, Tim Chase wrote:
> On 2014-02-06 17:40, Mark Lawrence wrote:
>> On 06/02/2014 14:02, Neil Cerutti wrote:
>> >
>> > You must open the file in binary mode, as that is what the csv
>> > module expects in Python 2.7. newline handling can be enscrewed
>> > if you forget.
>> >
>> > file =
On 06/02/2014 17:40, Mark Lawrence wrote:
On 06/02/2014 14:02, Neil Cerutti wrote:
You must open the file in binary mode, as that is what the csv
module expects in Python 2.7. newline handling can be enscrewed
if you forget.
file = open('raw.csv', 'b')
I've never opened a file in binary mod
On 2014-02-06 17:40, Mark Lawrence wrote:
> On 06/02/2014 14:02, Neil Cerutti wrote:
> >
> > You must open the file in binary mode, as that is what the csv
> > module expects in Python 2.7. newline handling can be enscrewed
> > if you forget.
> >
> > file = open('raw.csv', 'b')
> >
>
> I've never
On 06/02/2014 14:02, Neil Cerutti wrote:
You must open the file in binary mode, as that is what the csv
module expects in Python 2.7. newline handling can be enscrewed
if you forget.
file = open('raw.csv', 'b')
I've never opened a file in binary mode to read with the csv module
using any Py
On 2014-02-06, Zhen Zhang wrote:
> Hi, every one.
>
> I am a second year EE student.
> I just started learning python for my project.
>
> I intend to parse a csv file with a format like
>
> 3520005,"Toronto (Ont.)",C >
> ,F,2503281,2481494,F,F,0.9,1040597,979330,630.1763,3972.4,1
[...]
into a t
On Thursday, February 6, 2014 6:46:37 PM UTC+5:30, MRAB wrote:
>
> It's actually the comma that makes it a tuple (except for the 0-tuple
> "()"); it's just that it's often necessary to wrap it in (...), and
> people then think it's those that are making it a tuple, but it's not!
Interesting viewp
On 2014-02-06 07:52, Zhen Zhang wrote:> On Wednesday, February 5, 2014
7:33:00 PM UTC-5, Roy Smith wrote:
>> In article <5c268845-003f-4e24-b27a-c89e9fbfc...@googlegroups.com>,
>> Zhen Zhang wrote:
>>
>> > [code]
>> >
>> > import csv
>> > file = open('raw.csv')
>> > reader = csv.reader(file)
>>
Dave Angel Wrote in message:
> Zhen Zhang Wrote in message:
>>
>
>> I am currently running python 2.7.
>>
>> Yes, i thought there must be a print function in python like fprint in C++
>> that allows you to print into a file directly.
>> But i google about "print string into text file" I got
Zhen Zhang Wrote in message:
>
> I am currently running python 2.7.
>
> Yes, i thought there must be a print function in python like fprint in C++
> that allows you to print into a file directly.
> But i google about "print string into text file" I got answers using
> f.write() instead. :)
>
Zhen Zhang writes:
...
> I am currently running python 2.7.
>
> Yes, i thought there must be a print function in python like fprint
> in C++ that allows you to print into a file directly.
>
> But i google about "print string into text file" I got answers using
> f.write() instead. :)
Indeed. The
On Thursday, February 6, 2014 10:15:14 AM UTC+2, Asaf Las wrote:
> On Thursday, February 6, 2014 9:52:43 AM UTC+2, Zhen Zhang wrote:
> case it will be file name.
little correction not a file name - file object, file_t is result from open()
as you did in your example
--
https://mail.python.org/
On Thursday, February 6, 2014 9:52:43 AM UTC+2, Zhen Zhang wrote:
> On Wednesday, February 5, 2014 7:33:00 PM UTC-5, Roy Smith wrote:
> I failed to figure out why.
OK, you had to look to what i posted second time. The first one is
irrelevant. Note that file was emulated using StringIO. in your
c
On Wednesday, February 5, 2014 7:57:26 PM UTC-5, Dave Angel wrote:
> Zhen Zhang Wrote in message:
>
> > Hi, every one.
>
> >
>
> > I am a second year EE student.
>
> > I just started learning python for my project.
>
> >
>
> > I intend to parse a csv file with a format like
>
> >
>
> >
On Wednesday, February 5, 2014 7:46:04 PM UTC-5, Tim Chase wrote:
> On 2014-02-05 16:10, Zhen Zhang wrote:
>
> > import csv
>
> > file = open('raw.csv')
>
>
>
> Asaf recommended using string methods to split the file. Keep doing
>
> what you're doing (using the csv module), as it attends to
On Wednesday, February 5, 2014 7:34:57 PM UTC-5, MRAB wrote:
> On 2014-02-06 00:10, Zhen Zhang wrote:
>
> > Hi, every one.
>
> >
>
> > I am a second year EE student.
>
> > I just started learning python for my project.
>
> >
>
> > I intend to parse a csv file with a format like
>
> >
>
> >
On Wednesday, February 5, 2014 7:17:17 PM UTC-5, Asaf Las wrote:
> On Thursday, February 6, 2014 2:10:16 AM UTC+2, Zhen Zhang wrote:
>
> > Hi, every one.
>
> > Zhen
>
> str_t = '3520005,"Toronto (Ont.)",C
> ,F,2503281,2481494,F,F,0.9,1040597,979330,630.1763,3972.4,1'
>
> list_t = str_t.split
On Wednesday, February 5, 2014 7:33:00 PM UTC-5, Roy Smith wrote:
> In article <5c268845-003f-4e24-b27a-c89e9fbfc...@googlegroups.com>,
>
> Zhen Zhang wrote:
>
>
>
> > [code]
>
> >
>
> > import csv
>
> > file = open('raw.csv')
>
> > reader = csv.reader(file)
>
> >
>
> > f = open('Nice
On Thursday, February 6, 2014 6:09:52 AM UTC+2, Tim Chase wrote:
> On 2014-02-05 19:59, Asaf Las wrote:
> From your code,
> list_t = str_t.split(',')
> It might have been a short-hand for obtaining the results of a CSV
> row, but it might be better written something like
> list_t = csv.reader([
On 2014-02-05 19:59, Asaf Las wrote:
> On Thursday, February 6, 2014 2:46:04 AM UTC+2, Tim Chase wrote:
> > On 2014-02-05 16:10, Zhen Zhang wrote:
> > Asaf recommended using string methods to split the file. Keep
> > doing what you're doing (using the csv module), as it attends to
> > a lot of edg
On Thursday, February 6, 2014 2:46:04 AM UTC+2, Tim Chase wrote:
> On 2014-02-05 16:10, Zhen Zhang wrote:
> Asaf recommended using string methods to split the file. Keep doing
> what you're doing (using the csv module), as it attends to a lot of
> edge-cases that will trip you up otherwise. I lea
On 2/5/2014 7:10 PM, Zhen Zhang wrote:
Hi, every one.
I am a second year EE student.
I just started learning python for my project.
I intend to parse a csv file with a format like
3520005,"Toronto (Ont.)",C
,F,2503281,2481494,F,F,0.9,1040597,979330,630.1763,3972.4,1
2466023,"Montréal (Que.)"
On 06/02/2014 00:46, Tim Chase wrote:
On 2014-02-05 16:10, Zhen Zhang wrote:
import csv
file = open('raw.csv')
Asaf recommended using string methods to split the file. Keep doing
what you're doing (using the csv module), as it attends to a lot of
edge-cases that will trip you up otherwise. I
On 2014-02-05 16:10, Zhen Zhang wrote:
> import csv
> file = open('raw.csv')
Asaf recommended using string methods to split the file. Keep doing
what you're doing (using the csv module), as it attends to a lot of
edge-cases that will trip you up otherwise. I learned this the hard
way several yea
On 2014-02-06 00:10, Zhen Zhang wrote:
Hi, every one.
I am a second year EE student.
I just started learning python for my project.
I intend to parse a csv file with a format like
3520005,"Toronto (Ont.)",C
,F,2503281,2481494,F,F,0.9,1040597,979330,630.1763,3972.4,1
2466023,"Montréal (Que.)"
In article <5c268845-003f-4e24-b27a-c89e9fbfc...@googlegroups.com>,
Zhen Zhang wrote:
> [code]
>
> import csv
> file = open('raw.csv')
> reader = csv.reader(file)
>
> f = open('NicelyDone.text','w')
>
> for line in reader:
> f.write("%s %s"%line[1],%line[5])
>
> [/code]
Are you using
On Thursday, February 6, 2014 2:10:16 AM UTC+2, Zhen Zhang wrote:
> Hi, every one.
> Zhen
str_t = '3520005,"Toronto (Ont.)",C
,F,2503281,2481494,F,F,0.9,1040597,979330,630.1763,3972.4,1'
list_t = str_t.split(',')
print(list_t)
print("split result ", list_t[1], list_t[5])
print(list_t[1].split('"
Hi, every one.
I am a second year EE student.
I just started learning python for my project.
I intend to parse a csv file with a format like
3520005,"Toronto (Ont.)",C
,F,2503281,2481494,F,F,0.9,1040597,979330,630.1763,3972.4,1
2466023,"Montréal (Que.)",V
,F,1620693,1583590,T,F,2.3,787060,7
29 matches
Mail list logo