Steve wrote:
> My program reads from a text file (A), modifies the data, and writes to
> another file (B). This works until I reach about 300 writes and no more
> lines are written to file (B).
>
> I had to create a Counter and increment it to 250 when it gets reset.
>
> Upon reset, I close the
ytes) instead of the incoming data, 250+ times?
Footnote:
Ultrasound Technician Asks Pregnant Woman If She’d Like to Know Baby’s Name...
-Original Message-
From: DL Neil
Sent: Tuesday, February 12, 2019 2:13 PM
To: Steve ; python-list@python.org
Subject: Re: A limit to writing to a file from a loo
Steve,
On 13/02/19 7:56 AM, Steve wrote:
My program reads from a text file (A), modifies the data, and writes to another
file (B).
This works until I reach about 300 writes and no more lines are written to file
(B).
I had to create a Counter and increment it to 250 when it gets reset.
Upon res
On Wed, Feb 13, 2019 at 5:58 AM Steve wrote:
>
> My program reads from a text file (A), modifies the data, and writes to
> another file (B).
> This works until I reach about 300 writes and no more lines are written to
> file (B).
>
> I had to create a Counter and increment it to 250 when it gets
My program reads from a text file (A), modifies the data, and writes to another
file (B).
This works until I reach about 300 writes and no more lines are written to file
(B).
I had to create a Counter and increment it to 250 when it gets reset.
Upon reset, I close the file (B) being written a
a socket requires argument
> to be of type 'bytes'
Correct. Sockets are low-level endpoint for transmitting bytes between
processes.
> (otherwise python throw 'str does not support
> buffer interface...' exception), while writing to a file requires
>
"Yubin Ruan" wrote in message
news:47f3acf9-8da2-4aad-a6f0-7a9efbdfe...@googlegroups.com...
In my understanding, writing to a file would requires that everything be
written byte by byte. So writing objects of type 'bytes' to socket makes
sense. But, how could python
On Fri, Jul 22, 2016 at 6:52 PM, Yubin Ruan wrote:
> In my understanding, writing to a file would requires that everything be
> written byte by byte. So writing objects of type 'bytes' to socket makes
> sense. But, how could python write to file using unicode(type
se python throw 'str does not support
buffer interface...' exception), while writing to a file requires argument to
be of type 'str'. Why is that? In standard UNIX interface, everything is file,
which mean that writing to a socket is the same as writing to a normal file.
Th
Ganesh Pal wrote:
> On Sun, Jan 11, 2015 at 2:17 PM, Dave Angel wrote:
>>
>>
>> You chopped off the output there. It probably looked like this:
>>
>>
>> node-1# cat test_2.txt
>> Sundaynode-1#
>>
>>
>> Your output is there, right before the prompt. Since you neglected the
>> newline in your cod
On Sun, Jan 11, 2015 at 2:17 PM, Dave Angel wrote:
>
>
> You chopped off the output there. It probably looked like this:
>
>
> node-1# cat test_2.txt
> Sundaynode-1#
>
>
> Your output is there, right before the prompt. Since you neglected the
> newline in your code, that's what you'd expect, wou
You accidentally did a Reply instead of a Reply-List. So the email came
to me and not to the list. if your mail program doesn't support
reply-list, do a reply-all and remove the personal addresses. The list
is what's important here.
On 01/11/2015 12:20 AM, Ganesh Pal wrote:
On Sat, Jan 10,
Ganesh Pal wrote:
> Throttling-1# cat test_2.txt
Are you running these scripts as root? That could be a bad idea. If you have
a bug in your code, as often happens when coding, who knows what it might
do. E.g. if you put in the wrong pathname, you could overwrite important
files. You should always
On 01/10/2015 10:14 AM, Ganesh Pal wrote:
Please provide you input on the below questions:
For each new thread, you should specify at a minimum your Python version
and OS. it frequently matters, and it's better to specify than to have
everyone try to guess. I'll assume Python 2.7 and Linux
Please provide you input on the below questions:
(a) I was expecting the string i.e day of week , example Saturday to be
written in the file. what Iam I missing in the below program ?
Program:
#!/usr/bin/python
import time
f = open ('test_2.txt','w+b')
DAY = time.strftime("%A")
f.write(DAY)
On 15/02/2012 20:12, Rituparna Sengupta wrote:
Hi,
I'm working on this code and I keep getting an error. It might be some very
basic thing but I was wondering if someone could help. Its a loop within a
loop. The part outside the innermost loop gets printed fine, but the part
within the innerm
On 02/15/2012 03:12 PM, Rituparna Sengupta wrote:
Hi,
I'm working on this code and I keep getting an error. It might be some very
basic thing but I was wondering if someone could help. Its a loop within a
loop. The part outside the innermost loop gets printed fine, but the part
within the inn
On Wed, Feb 15, 2012 at 12:12 PM, Rituparna Sengupta wrote:
> Hi,
>
> I'm working on this code and I keep getting an error. It might be some very
> basic thing but I was wondering if someone could help. Its a loop within a
> loop. The part outside the innermost loop gets printed fine, but the pa
On Wed, Feb 15, 2012 at 1:12 PM, Rituparna Sengupta wrote:
> Hi,
>
> I'm working on this code and I keep getting an error. It might be some very
> basic thing but I was wondering if someone could help. Its a loop within a
> loop. The part outside the innermost loop gets printed fine, but the par
Hi,
I'm working on this code and I keep getting an error. It might be some very
basic thing but I was wondering if someone could help. Its a loop within a
loop. The part outside the innermost loop gets printed fine, but the part
within the innermost loop doesn't get printed. I get an error: 'st
On Jan 12, 6:21 pm, MRAB wrote:
> On 12/01/2012 22:26, Denhua wrote:
>
>
>
>
>
>
>
> > Hi,
>
> > I've got a file which I'd like to read, modify and write.
>
> > # file contents
> > a
> > b
> > c
> > d
>
> > My script reads the file contents into a list and rotates the list and
> > writes it back t
On 12/01/2012 22:26, Denhua wrote:
Hi,
I've got a file which I'd like to read, modify and write.
# file contents
a
b
c
d
My script reads the file contents into a list and rotates the list and
writes it back to the same file.
Problem is that the output contains null characters. I don't know
whe
In article
<4f7d125a-2713-4b57-a108-2a56ae653...@h3g2000yqe.googlegroups.com>,
Denhua wrote:
> [omitted]
> f.write("\n".join(newlist))
> f.close()
>
> # output
>
> [root@Inferno html]# python rotate.py
> ['b', 'c', 'd', 'a']
> [root@Inferno html]# python rotate.py
> ['c', 'd', 'a', '\x00\x00\
Hi,
I've got a file which I'd like to read, modify and write.
# file contents
a
b
c
d
My script reads the file contents into a list and rotates the list and
writes it back to the same file.
Problem is that the output contains null characters. I don't know
where they are coming from.
#!/usr/bin/
Roger House writes:
> I tried PyRun_String, but I can't see how it can be used to return a
> tuple (the Py_file_input option always returns None).
There's an example of this at
http://stackoverflow.com/questions/3789881/create-and-call-python-function-from-string-via-c-api
The comments say this
On Sat, Apr 16, 2011 at 9:46 AM, Roger House wrote:
> I'm a Python newbie who's been given a task requiring calls of Python code
> from a C++ program. I've tried various tutorials and dug into The Python/C
> API doc and the Extending and Embedding Python doc, but I haven't been able
> to answer t
I'm a Python newbie who's been given a task requiring calls of Python code
from a C++ program. I've tried various tutorials and dug into The Python/C
API doc and the Extending and Embedding Python doc, but I haven't been able
to answer this question:
Is it possible in a C++ program to genera
I appreciate you all taking the time to answer my question.
These were the types of things I was needing to hear.
Sorry for any confusion I may have caused by using a
relative file path with the '~'… I was typing from
memory and didn't think about it beforehand.
Eryksun, thank you for the in
On Sat, 26 Mar 2011 14:49:31 +1300, Gregory Ewing wrote:
> jyoun...@kc.rr.com wrote:
>
>import os
>os.system('echo "Testing a... b... c..." > "~/Desktop/test2.txt"')
>
> This is like going out the back door, getting a ladder out of the shed
> and climbing through your bedroom window to g
On Fri, 25 Mar 2011 19:39:11 -0600, Littlefield, Tyler wrote:
> >with open(test_absname, 'w') as test:
> what's the difference in that and test = ...? I can see why you mentioned
> the os.path for cross-platform, but I don't understand why someone would
> use with over =.
Using "with" will a
On Friday, March 25, 2011 9:39:11 PM UTC-4, Littlefield, Tyler wrote:
> >with open(test_absname, 'w') as test:
> what's the difference in that and test = ...? I can see why you
> mentioned the os.path for cross-platform, but I don't understand why
> someone would use with over =.
It avoids h
with closes the file for you, when the indented block is exited.
~ isn't cross-platform at all, in fact it's not precisely python, though
os.path.expanduser understands it.
AFAIK, the jury's still out on whether the /'s in pathnames as directory
separators are portable. I know they work on *ix a
jyoun...@kc.rr.com wrote:
import os
os.system('echo "Testing a... b... c..." > "~/Desktop/test2.txt"')
This is like going out the back door, getting a ladder out of
the shed and climbing through your bedroom window to get into
bed at night, instead of just using the stairs.
Use open/write/clo
John Gordon wrote:
The write() way is much better. (However, I'm not sure it will do what
you were expecting with the tilde in the file path.)
It won't, but the os.path.expanduser() function can
be used to fix that.
--
Greg
--
http://mail.python.org/mailman/listinfo/python-list
>with open(test_absname, 'w') as test:
what's the difference in that and test = ...? I can see why you
mentioned the os.path for cross-platform, but I don't understand why
someone would use with over =.
On 3/25/2011 7:11 PM, eryksun () wrote:
On Friday, March 25, 2011 11:07:19 AM UTC-4, jy
On Friday, March 25, 2011 11:07:19 AM UTC-4, jyou...@kc.rr.com wrote:
>
> >>> f = open('~/Desktop/test.txt', 'w')
> >>> f.write('testing 1... 2... 3...')
> >>> f.close()
Consider using "with" to automatically close the file and os.path for
cross-platform compatibility:
import os.path
use
On Fri, 2011-03-25 at 15:07 +, jyoun...@kc.rr.com wrote:
> Just curious how others view the 2 examples below for creating and
> writing to a file in Python (in OS X). Is one way better than the other?
> If it was a large amount of text, would the 'os.system' call be a
In
writes:
> Just curious how others view the 2 examples below for creating and
> writing to a file in Python (in OS X). Is one way better than the other?
> If it was a large amount of text, would the 'os.system' call be a bad
> way to do it?
The write() way is
On Mar 25, 8:07 am, wrote:
> Just curious how others view the 2 examples below for creating and
> writing to a file in Python (in OS X). Is one way better than the other?
> If it was a large amount of text, would the 'os.system' call be a bad
> way to do it?
>
> T
Just curious how others view the 2 examples below for creating and
writing to a file in Python (in OS X). Is one way better than the other?
If it was a large amount of text, would the 'os.system' call be a bad
way to do it?
Thanks.
Jay
>>> f = open('~/Desktop/tes
Thanks yes that did it.
"Peter Otten" <__pete...@web.de> wrote in message
news:gspmrf$qlq$0...@news.t-online.com...
> Carbon Man wrote:
>
>> Py 2.5
>> Trying to write a string to a file.
>> self.dataUpdate.write(u"\nentry."+node.tagName+ u" = " + cValue)
>> cValue contains a unicode character. no
Carbon Man wrote:
> Py 2.5
> Trying to write a string to a file.
> self.dataUpdate.write(u"\nentry."+node.tagName+ u" = " + cValue)
> cValue contains a unicode character. node.tagName is also a unicode string
> though it has no special characters in it.
> Getting the error:
> UnicodeEncodeError: '
Carbon Man wrote:
> self.dataUpdate.write(u"\nentry."+node.tagName+ u" = " + cValue)
> cValue contains a unicode character. node.tagName is also a unicode string
> though it has no special characters in it.
> Getting the error:
> UnicodeEncodeError: 'ascii' codec can't encode character u'\x93' in
>
Carbon Man wrote:
> Py 2.5
> Trying to write a string to a file.
> self.dataUpdate.write(u"\nentry."+node.tagName+ u" = " + cValue)
> cValue contains a unicode character. node.tagName is also a unicode string
> though it has no special characters in it.
> Getting the error:
> UnicodeEncodeError: '
Carbon Man wrote:
Py 2.5
Trying to write a string to a file.
self.dataUpdate.write(u"\nentry."+node.tagName+ u" = " + cValue)
cValue contains a unicode character. node.tagName is also a unicode string
though it has no special characters in it.
So what's the encoding of your file?
If you didn
Py 2.5
Trying to write a string to a file.
self.dataUpdate.write(u"\nentry."+node.tagName+ u" = " + cValue)
cValue contains a unicode character. node.tagName is also a unicode string
though it has no special characters in it.
Getting the error:
UnicodeEncodeError: 'ascii' codec can't encode charac
When you use "print," it automatically adds a newline (\n).
You can avoid this by following the print line with a comma:
print j,
Or rstrip() the line before printing. Either way.
--
http://mail.python.org/mailman/listinfo/python-list
On May 30, 4:53 pm, sturlamolden <[EMAIL PROTECTED]> wrote:
> However, numpy has a properly working memory mapped array class,
> numpy.memmap.
It seems that NumPy's memmap uses a buffer from mmap, which makes both
of them defunct for large files. Damn.
mmap must be fixed.
--
http://mail.p
On May 30, 4:53 pm, sturlamolden <[EMAIL PROTECTED]> wrote:
> import numpy
>
> byte = numpy.uint8
> desc = numpy.dtype({'names':['r','g','b'],'formats':[byte,byte,byte]})
> mm = numpy.memmap('myfile.dat', dtype=desc, offset=4096,
> shape=(480,640), order='C')
> red = mm['r']
> green = mm['g']
> bl
On May 30, 1:41 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> [EMAIL PROTECTED] schrieb:
> > what i want to know is which one is faster (if there is any difference
> > in speed) since i'm working with very large files. of course, if there
> > is any other way to write data to a file, i'd lov
[EMAIL PROTECTED] schrieb:
> as i understand there are two ways to write data to a file: using
> f.write("foo") and print >>f, "foo".
> what i want to know is which one is faster (if there is any difference
> in speed) since i'm working with very large files. of course, if there
> is any other way
[EMAIL PROTECTED] wrote:
> as i understand there are two ways to write data to a file: using
> f.write("foo") and print >>f, "foo".
well print will add a '\n' or ' ' if you use ',' after it
> what i want to know is which one is faster (if there is any difference
there shouldn't be any noticable d
as i understand there are two ways to write data to a file: using
f.write("foo") and print >>f, "foo".
what i want to know is which one is faster (if there is any difference
in speed) since i'm working with very large files. of course, if there
is any other way to write data to a file, i'd love to
Eduardo Biano wrote:
> I am a python newbie and I have a problem with writing
> each record read to a file. The expected output is 10
> rows of records, but the actual output of the code
> below is only one row with a very long record (10
> records are lump into one record). Thank you in
> advance
Eduardo Biano wrote:
> #---
> # This is the problem code. Ten records
> # is lump into 1 row and written
> # in the output file.
> #
> # My expected output is 10 rows.
> #---
> info = string.join([fn, mi, ln, deg, dat]
Should pr
I am a python newbie and I have a problem with writing
each record read to a file. The expected output is 10
rows of records, but the actual output of the code
below is only one row with a very long record (10
records are lump into one record). Thank you in
advance for your help. Here is the code:
56 matches
Mail list logo