FAQ
I am writing a python script that through the
os.system command calls VSS and imports the files
over. I then run
os.system('dir /s >> myfile.txt')

I want to be able to read in the contents of the
file one line at a time and execute some command
on it. My problem is when the file is something
like C:\program files\python\temporary Python
reads it as c:\program files\python\011emporary

I am getting tripped up by the \t switch. I
cannot at this point and time run string.replace
because it has already been converted over. Any
ideas how I can read the string in correctly? I
have explored the glob module and it would seem
very cumbersome to try and cover this. Is there
an easier way to read in the contents of my file
and have them import correctly?


Sent via Deja.com http://www.deja.com/
Before you buy.

Search Discussions

  • Laurent POINTAL at May 17, 2000 at 11:56 am

    On Wed, 17 May 2000 02:58:09 GMT, ghost_man at my-deja.com wrote:
    : I am writing a python script that through the
    : os.system command calls VSS and imports the files
    : over. I then run
    : os.system('dir /s >> myfile.txt')
    :
    : I want to be able to read in the contents of the
    : file one line at a time and execute some command
    : on it. My problem is when the file is something
    : like C:\program files\python\temporary Python
    : reads it as c:\program files\python\011emporary
    :
    : I am getting tripped up by the \t switch. I
    : cannot at this point and time run string.replace
    : because it has already been converted over. Any
    : ideas how I can read the string in correctly? I
    : have explored the glob module and it would seem
    : very cumbersome to try and cover this. Is there
    : an easier way to read in the contents of my file
    : and have them import correctly?
    How do you open and read your file?

    open(filename,"r").read() to get all the file in a whole blok.
    open(filename,"r").readlines() to get all the file in a list of lines.

    Normally read and readlines may not interpret \ escape sequences.

    A+

    Laurent.

    ---
    Laurent POINTAL - CNRS/LURE - Service Informatique Experiences
    Tel/fax: 01 64 46 82 80 / 01 64 46 41 48
    email : pointal at lure.u-psud.fr ou lpointal at planete.net
  • Emile at May 17, 2000 at 1:48 pm
    I've got a feeling you're getting tripped up
    parsing and passing on the names to the next
    command you want done.

    Pare down your code to a sub-set that exhibits
    the problem, then post it and we can help better.

    Emile van Sebille
    emile at fenx.com

    <ghost_man at my-deja.com> wrote in message
    news:<8ft1rq$pgb$1 at nnrp1.deja.com>...
    I am writing a python script that through the
    os.system command calls VSS and imports the files
    over. I then run
    os.system('dir /s >> myfile.txt')

    I want to be able to read in the contents of the
    file one line at a time and execute some command
    on it. My problem is when the file is something
    like C:\program files\python\temporary Python
    reads it as c:\program files\python\011emporary

    I am getting tripped up by the \t switch. I
    cannot at this point and time run string.replace
    because it has already been converted over. Any
    ideas how I can read the string in correctly? I
    have explored the glob module and it would seem
    very cumbersome to try and cover this. Is there
    an easier way to read in the contents of my file
    and have them import correctly?


    Sent via Deja.com http://www.deja.com/
    Before you buy.
    --
    http://www.python.org/mailman/listinfo/python-list
  • Niels Diepeveen at May 18, 2000 at 4:06 pm
    ghost_man at my-deja.com schreef:
    I am writing a python script that through the
    os.system command calls VSS and imports the files
    over. I then run
    os.system('dir /s >> myfile.txt')
    It seems to me that what you really want is os.listdir()

    --
    Niels Diepeveen
    Endea automatisering
  • Niels Diepeveen at May 18, 2000 at 6:59 pm
    Niels Diepeveen schreef:
    ghost_man at my-deja.com schreef:
    os.system('dir /s >> myfile.txt')
    ^^
    It seems to me that what you really want is os.listdir()
    Sorry, make that os.path.walk()

    --
    Niels Diepeveen
    Endea automatisering

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedMay 17, '00 at 2:58a
activeMay 18, '00 at 6:59p
posts5
users4
websitepython.org

People

Translate

site design / logo © 2022 Grokbase