On Mon, Dec 8, 2008 at 12:15 PM, Sander Sweers <[EMAIL PROTECTED]> wrote:
> Hello All, I was playing around with the zipfile module and wrote a
> simple script to unzip a zip file. I then looked around on the
> internet and found the recipe 252508 [1] on the active state cookbook
> website.
>
> In
Hello All, I was playing around with the zipfile module and wrote a
simple script to unzip a zip file. I then looked around on the
internet and found the recipe 252508 [1] on the active state cookbook
website.
In this recipe the author calls flush() and then close() on a file
object being written
the code is way to long but i can post the output of puzzleanswers
Answer:
6 1 4 2 9 3 8 5 7
8 5 9 1 6 7 2 3 4
2 3 7 8 5 4 9 1 6
7 8 6 9 1 2 5 4 3
4 2 1 3 7 5 6 9 8
3 9 5 4 8 6 1 7 2
9 4 3 5 2 8 7 6 1
5 6 8 7 4 1 3 2 9
1 7 2 6 3 9 4 8 5
for those of you who dont know its a sudoku puzzle if you gu
>> How do you know? Where are you looking for the file?
>> Are you sure its not a Path issue?
> no no the file shows up in the same directory as the .py file and i
> no it
> works cause i read the text file
OK, In that case can you show us what puzzleanswers looks like?
>> > On 8/29/06, Kent Jo
no no the file shows up in the same directory as the .py file and i no it works cause i read the text fileOn 8/29/06, Alan Gauld <
[EMAIL PROTECTED]> wrote:>i do and they have writing but its just not printing it at all
>How do you know? Where are you looking for the file?Are you sure its not a Pat
>i do and they have writing but its just not printing it at all
>
How do you know? Where are you looking for the file?
Are you sure its not a Path issue?
Alan G.
> On 8/29/06, Kent Johnson <[EMAIL PROTECTED]> wrote:
>>
>> Amadeo Bellotti wrote:
>> > Ok im trying to create a file that the user
well i made a typo and puzzleanswers was empty i fixed it and it works fine thank you guys so muchOn 8/29/06, Bob Gailer <
[EMAIL PROTECTED]> wrote:Amadeo Bellotti wrote:> Ok im trying to create a file that the user chooses the name of and
> print a varible that is a string to the text file. but fo
Amadeo Bellotti wrote:
> Ok im trying to create a file that the user chooses the name of and
> print a varible that is a string to the text file. but for some reason
> whne i do this code:
>
> FILE = open(filename, "w")
> FILE.write(puzzleanswers)
> FILE.close()
>
> it doesnt write anything
That
i do and they have writing but its just not printing it at allOn 8/29/06, Kent Johnson <[EMAIL PROTECTED]> wrote:
Amadeo Bellotti wrote:> Ok im trying to create a file that the user chooses the name of and print a
> varible that is a string to the text file. but for some reason whne i do> this code
Amadeo Bellotti wrote:
> Ok im trying to create a file that the user chooses the name of and print a
> varible that is a string to the text file. but for some reason whne i do
> this code:
>
> FILE = open(filename, "w")
> FILE.write(puzzleanswers)
> FILE.close()
>
> it doesnt write anything does an
Ok im trying to create a file that the user chooses the name of and
print a varible that is a string to the text file. but for some reason
whne i do this code:
FILE = open(filename, "w")
FILE.write(puzzleanswers)
FILE.close()
it doesnt write anything does anyone know how to fix it so it works?
_
"Carroll, Barry" <[EMAIL PROTECTED]> wrote:
Second, your current logic is assembling the data from each line into a
string. Is that what you want? I'm guessing you want to extract the three
fields into a three element list. If so, you need to turn the three strings
(fields[1], fields[2] and fie
[snip] Colin: your replies to 2 e-mails indicate that you have either not
read the e-mails or the prior responses. Please consider the work others
put into replying before replying.
Example: I suggested % formatting in a reply. You replied to that by saying
the same thing.
Michael Haft wrote:
>Hello,
> I tried the following code:
>
>def readSOMNETM(inputName):
>input = open(inputName, "r")
>result = []
>for line in input:
>fields = line.split()
>data = fields[1] + fields[2] + fields[7]
>result.append(data)
>input.close()
>
Michael Haft wrote:
> Hello,
> I tried the following code:
>
> def readSOMNETM(inputName):
> input = open(inputName, "r")
> result = []
> for line in input:
> fields = line.split()
> data = fields[1] + fields[2] + fields[7]
> result.append(data)
> input
ields[7]]
> --
> Date: Thu, 3 Nov 2005 22:10:02 - (GMT)
> From: "Mike Haft" <[EMAIL PROTECTED]>
> Subject: Re: [Tutor] File IO
> To: "bob" <[EMAIL PROTECTED]>
> Cc: tutor@python.org
> Message-ID: <[EMAIL PRO
ur problem.
In your loop, I'd recommend you check and ignore your header.
either -
result = []
pastHeader = False
for line in input:
if not pastHeader:
if line.startswith("***"):
pastHeader = True #Will be shortly, anyway.
continu
Woah, that's way simpler than mine.
Liam Clarke-Hutchinson
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of bob
Sent: Friday, 4 November 2005 11:01 a.m.
To: [EMAIL PROTECTED]; tutor@python.org
Subject: Re: [Tutor] File IO
At 01:34 PM 11/3/2005, Mi
I did that and got this:
Here goes
Enter filename:
Name:LAU73M.MET
Line too short Monthly Weather Data, LAU73M.MET, converted from:
Line too short BAD LAUCHSTAEDT; DAILY METEOROLOGICAL DATA FOR
01/01/1973-31/12/1973
Line too short
*
At 01:34 PM 11/3/2005, Michael Haft wrote:
>Hello,
> I tried the following code:
>
>def readSOMNETM(inputName):
> input = open(inputName, "r")
> result = []
> for line in input:
> fields = line.split()
# add this; it will show you what line(s) have less than 8 f
Hello,
I tried the following code:
def readSOMNETM(inputName):
input = open(inputName, "r")
result = []
for line in input:
fields = line.split()
data = fields[1] + fields[2] + fields[7]
result.append(data)
input.close()
return result
print "Here g
Heh,
Cut 'im some slack there Bob, I only just figured out that line[:1] ==
line[0]...
On 10/28/05, bob <[EMAIL PROTECTED]> wrote:
> At 01:42 PM 10/27/2005, Adam wrote:
> > >if line[:1] == "1":
> >
> >This line won't work because you're getting the first 2 characters from
> >the line
>
> Oh? Did
Oops,
filePaths = [os.path.join(direc, item) for item in os.listdir(direc)
if not os.path.isdir(os.path.join(direc, item))]
should be
> filePaths = [os.path.join(dirPath, item) for item in os.listdir(dirPath)
> if not os.path.isdir(os.path.join(dirPath, item))]
...
__
Mike Haft wrote:
> Hello all,
> I'm new to python but so far I have to say its a really good language
>
> I've been having some trouble with File IO can anyone help? I've got the
> basics but my problem is that I have many files (one for each year of the
> last 100 years or so) that look l
At 01:42 PM 10/27/2005, Adam wrote:
> >if line[:1] == "1":
>
>This line won't work because you're getting the first 2 characters from
>the line
Oh? Did you test that? When I do that I get 1 character. Why? Because
slicing goes UP TO the 2nd argument.
>>> 'abc'[:1]
'a'
>if line[:1] == "1":
This line won't work because you're getting the first 2 characters from
the line and seeing if it's equal to a string of length one. For
example in your test file if you put this line,
1 12.4 12.0 * 10 ,
through that bit of code it would see if "1 " == "1", which
At 12:18 PM 10/27/2005, Mike Haft wrote:
>Apologies for not making things clearer last time.
>
>My specific problems are:
>
>why can I not get the readline() or readlines() functions to work, I'm
>told they are not defined whenever I try.
Mike * Oh * Mike ... and all others ...
Please Post The Co
On Thu, 27 Oct 2005, Mike Haft wrote:
> why can I not get the readline() or readlines() functions to work, I'm
> told they are not defined whenever I try.
Don't paraphrase. *grin*
Show us what you did in terms of the code that you ran. Also, include the
literal error message and its tracebac
Apologies for not making things clearer last time.
My specific problems are:
why can I not get the readline() or readlines() functions to work, I'm
told they are not defined whenever I try.
Also the following:
if line[:1] == "1":
collects data from month 1, 10, 11, and 12. How do I make the re
Hello all,
I'm new to python but so far I have to say its a really good language
I've been having some trouble with File IO can anyone help? I've got the
basics but my problem is that I have many files (one for each year of the
last 100 years or so) that look like this:
MONTH RAIN AVTE
http://uselesspython.com/tutorials/PythonFileIOStepByStep.pdf
I've written a quick step-by-step .pdf to walk through the process of
creating a new text file, read from it, and append to it with Python.
It doesn't cover every last thing one can do with opened files, but
does point to a few other re
--
... but this doesn't seem to work. The value that Python returns is:
'@\x19\x01\x00'
but I know from similar code in Matlab that the correct sequence is:
64 25 1 0
Can someone point out my error?
--
That
At 01:12 PM 7/6/2005, Marcus Goldfish wrote:
Hi,
I have a file format that ends in a 4-byte (int32) number. I
would
like to read this value in python on a WinXP machine with something
like:
fname = 'somefile'
f = open(fname, 'rb')
f.seek(-4,2)
offset = f.read()
... but this doesn't seem to work.
On Wed, 6 Jul 2005, Marcus Goldfish wrote:
> I have a file format that ends in a 4-byte (int32) number. I would like
> to read this value in python on a WinXP machine with something like:
>
> fname = 'somefile'
> f = open(fname, 'rb')
> f.seek(-4,2)
> offset = f.read()
>
> ... but this doesn't
Hi,
I have a file format that ends in a 4-byte (int32) number. I would
like to read this value in python on a WinXP machine with something
like:
fname = 'somefile'
f = open(fname, 'rb')
f.seek(-4,2)
offset = f.read()
... but this doesn't seem to work. The value that Python returns is:
'@\x
35 matches
Mail list logo