Re: [Tutor] reading files in Python 3

2017-03-31 Thread eryk sun
On Thu, Mar 30, 2017 at 8:45 PM, Mats Wichmann wrote: > Yeah, fun. You need to escape the \ that the idiot MS-DOS people chose > for the file path separator. Because \ is treated as an escape character. The COMMAND.COM shell inherited command-line switches (options) that use slash from TOPS-10 b

Re: [Tutor] reading files in Python 3

2017-03-31 Thread Mats Wichmann
On 03/31/2017 09:44 AM, Alex Kleider wrote: > On 2017-03-30 13:45, Mats Wichmann wrote: > >> >> Yeah, fun. You need to escape the \ that the idiot MS-DOS people chose >> for the file path separator. > > I also believe that the "MS-DOS people" are making a poor choice > but to call them idiots is

Re: [Tutor] reading files in Python 3

2017-03-31 Thread Alex Kleider
On 2017-03-30 13:45, Mats Wichmann wrote: Yeah, fun. You need to escape the \ that the idiot MS-DOS people chose for the file path separator. I also believe that the "MS-DOS people" are making a poor choice but to call them idiots is perhaps a bit strong. Remember that for many the use of Mi

Re: [Tutor] reading files in Python 3

2017-03-31 Thread Mats Wichmann
On 03/30/2017 11:02 AM, Rafael Knuth wrote: > I can read files like this (relative path): > > with open("Testfile_B.txt") as file_object: > contents = file_object.read() > print(contents) > > But how do I read files if I want to specify the location (absolute path): > > file_path = "C:\U

Re: [Tutor] reading files in Python 3

2017-03-30 Thread eryk sun
On Thu, Mar 30, 2017 at 8:47 PM, Zachary Ware wrote: > In this case, the problem is the bogus Unicode escape that you > inadvertently included in your path: `\Us...`. To fix it, either use a > 'raw' string (`r"C:\Users\..."`) or use forward slashes rather than > backslashes, which Windows is happ

Re: [Tutor] reading files in Python 3

2017-03-30 Thread Zachary Ware
On Mar 30, 2017 15:07, "Rafael Knuth" wrote: I can read files like this (relative path): with open("Testfile_B.txt") as file_object: contents = file_object.read() print(contents) But how do I read files if I want to specify the location (absolute path): file_path = "C:\Users\Rafael\Tes

Re: [Tutor] reading files

2014-01-29 Thread David Palao
2014-01-29 Mark Lawrence : > On 29/01/2014 14:50, Gabriele Brambilla wrote: >> >> thanks to everyone, I've used David's method. >> >> Gabriele >> >> 2014-01-29 Mark Lawrence > > >> >> >> On 29/01/2014 02:09, Gabriele Brambilla wrote: >> >> Hi, >>

Re: [Tutor] reading files

2014-01-29 Thread Mark Lawrence
On 29/01/2014 14:50, Gabriele Brambilla wrote: thanks to everyone, I've used David's method. Gabriele 2014-01-29 Mark Lawrence mailto:breamore...@yahoo.co.uk>> On 29/01/2014 02:09, Gabriele Brambilla wrote: Hi, how could I read float numbers if the data format is like this

Re: [Tutor] reading files

2014-01-29 Thread Gabriele Brambilla
thanks to everyone, I've used David's method. Gabriele 2014-01-29 Mark Lawrence > On 29/01/2014 02:09, Gabriele Brambilla wrote: > >> Hi, >> how could I read float numbers if the data format is like this (using >> readline): >> >> 1.0551951.26758123387023-0.314470329249

Re: [Tutor] reading files

2014-01-29 Thread Mark Lawrence
On 29/01/2014 02:09, Gabriele Brambilla wrote: Hi, how could I read float numbers if the data format is like this (using readline): 1.0551951.26758123387023-0.314470329249235 -0.293015360064208 6.157957619078221.92919102133526 13.07804596303782.151753

Re: [Tutor] reading files

2014-01-29 Thread Alan Gauld
On 29/01/14 02:09, Gabriele Brambilla wrote: how could I read float numbers if the data format is like this (using readline): 1.0551951.26758123387023-0.314470329249235 -0.293015360064208 6.157957619078221.92919102133526 the numbers aren't equally spaced

Re: [Tutor] Reading Files and Such

2008-10-09 Thread Alan Gauld
"Wayne Watson" <[EMAIL PROTECTED]> wrote Yes, listdir does not read files, it just prepares a list of all files in the folder. I work my way through them as needed. It looks like glob does something similar. Yes but glob can use wildcards to select only files matching the pattern (eg *.txt t

Re: [Tutor] Reading Files and Such

2008-10-09 Thread Wayne Watson
Title: Signature.html bob gailer wrote: Wayne Watson wrote: I have a Python application that requires the program be run in a specific folder, Win XP. It analyzes and modifies txt files there, and only txt files. The mods require creating a tmp file. The tmp files could just as well be a

Re: [Tutor] Reading Files and Such

2008-10-04 Thread bob gailer
Jaggo wrote: So, am I to understand from this lack of response there be *no particular reason* to use Temp file? AFAIC there is no particular reason to use Temp file. It is a convenience for those of us who need temp files and don't want to bother creating unique names. -- Bob Gailer Chapel

Re: [Tutor] Reading Files and Such

2008-09-29 Thread bob gailer
Wayne Watson wrote: I have a Python application that requires the program be run in a specific folder, Win XP. It analyzes and modifies txt files there, and only txt files. The mods require creating a tmp file. The tmp files could just as well be an xyz suffix file. That is, it seems as though

Re: [Tutor] reading files

2006-09-22 Thread Alan Gauld
>i cant understand the open command i tried the help command but still > dont get i am trying to write twi programs one to keep track of > money > phone numbers... and another to randomly print a statmint from a > file The built in open command opens a file. That is it creates a file object that