AUX File Writing Error

Discussion in 'Python' started by thewritersclub@gmail.com, Feb 15, 2007.

  1. Guest

    Hi guys!

    I'm new to python so please be aware that I'm probably missing the
    obvious. Here's my problem...

    >>> t = "AUX"
    >>> f = open('c:\\' + t + '.csv', 'a')


    Traceback (most recent call last):
    File "<pyshell#37>", line 1, in <module>
    f = open('c:\\' + t + '.csv', 'a')
    IOError: [Errno 2] No such file or directory: 'c:\\AUX.csv'
    >>> t = "A"
    >>> f = open('c:\\' + t + '.csv', 'a')
    >>>


    As you can see python has no problem opening a file when t = "A", but
    not when it is "AUX" (no "A.csv" or "AUX.csv" exists on the C:\ folder
    prior to when these are run).

    Is there any way I can create an "AUX.csv" file without the error?

    Thanks,

    Ryan
     
    , Feb 15, 2007
    #1
    1. Advertising

  2. John Machin Guest

    On Feb 15, 4:03 pm, wrote:
    > Hi guys!
    >
    > I'm new to python so please be aware that I'm probably missing the
    > obvious. Here's my problem...
    >
    > >>> t = "AUX"
    > >>> f = open('c:\\' + t + '.csv', 'a')

    >
    > Traceback (most recent call last):
    > File "<pyshell#37>", line 1, in <module>
    > f = open('c:\\' + t + '.csv', 'a')
    > IOError: [Errno 2] No such file or directory: 'c:\\AUX.csv'
    >
    > >>> t = "A"
    > >>> f = open('c:\\' + t + '.csv', 'a')

    >
    > As you can see python has no problem opening a file when t = "A", but
    > not when it is "AUX" (no "A.csv" or "AUX.csv" exists on the C:\ folder
    > prior to when these are run).
    >
    > Is there any way I can create an "AUX.csv" file without the error?


    Probably not. AUX, CON, NUL, PRN, LPT, COM1, COM2 etc (with or without
    an extension) are reserved in Windows for specific devices for
    compatibility with MS-DOS 1.00 programs, which did that for
    compatibility with CP/M.

    HTH,
    John
     
    John Machin, Feb 15, 2007
    #2
    1. Advertising

  3. En Thu, 15 Feb 2007 03:34:59 -0300, John Machin <>
    escribió:

    > On Feb 15, 4:03 pm, wrote:
    >> Is there any way I can create an "AUX.csv" file without the error?

    >
    > Probably not. AUX, CON, NUL, PRN, LPT, COM1, COM2 etc (with or without
    > an extension) are reserved in Windows for specific devices for
    > compatibility with MS-DOS 1.00 programs, which did that for
    > compatibility with CP/M.


    (This is OT now) Do you know why "AUX.csv" is invalid too? I can accept
    that AUX (without extension) is an invalid filename, but it is quite
    different from "AUX.csv"

    --
    Gabriel Genellina
     
    Gabriel Genellina, Feb 15, 2007
    #3
  4. Steve Holden Guest

    Gabriel Genellina wrote:
    > En Thu, 15 Feb 2007 03:34:59 -0300, John Machin <>
    > escribió:
    >
    >> On Feb 15, 4:03 pm, wrote:
    >>> Is there any way I can create an "AUX.csv" file without the error?

    >> Probably not. AUX, CON, NUL, PRN, LPT, COM1, COM2 etc (with or without
    >> an extension) are reserved in Windows for specific devices for
    >> compatibility with MS-DOS 1.00 programs, which did that for
    >> compatibility with CP/M.

    >
    > (This is OT now) Do you know why "AUX.csv" is invalid too? I can accept
    > that AUX (without extension) is an invalid filename, but it is quite
    > different from "AUX.csv"
    >

    Because Windows is brain-dead? There really is no sense in looking for
    rationality where none exists. This is the way it is, and there's
    nothing you can do about it.

    regards
    Steve
    --
    Steve Holden +44 150 684 7255 +1 800 494 3119
    Holden Web LLC/Ltd http://www.holdenweb.com
    Skype: holdenweb http://del.icio.us/steve.holden
    Blog of Note: http://holdenweb.blogspot.com
    See you at PyCon? http://us.pycon.org/TX2007
     
    Steve Holden, Feb 15, 2007
    #4
  5. John Machin Guest

    On Feb 16, 12:13 am, "Gabriel Genellina" <>
    wrote:
    > En Thu, 15 Feb 2007 03:34:59 -0300, John Machin <>
    > escribió:
    >
    > > On Feb 15, 4:03 pm, wrote:
    > >> Is there any way I can create an "AUX.csv" file without the error?

    >
    > > Probably not. AUX, CON, NUL, PRN, LPT, COM1, COM2 etc (with or without
    > > an extension) are reserved in Windows for specific devices for
    > > compatibility with MS-DOS 1.00 programs, which did that for
    > > compatibility with CP/M.

    >
    > (This is OT now) Do you know why "AUX.csv" is invalid too? I can accept
    > that AUX (without extension) is an invalid filename, but it is quite
    > different from "AUX.csv"
    >


    It is actually a valid file name, but the file is not on disk. I
    presume that the OP got an error because it was in 'a' (append) mode
    which requires an existing disk file. See below.

    C:\junk>copy con aux.csv
    fubar
    ^Z
    1 file(s) copied.

    C:\junk>copy con sux.csv
    fubar
    ^Z
    1 file(s) copied.

    C:\junk>dir *ux.csv
    [snip]
    Directory of C:\junk

    16/02/2007 01:19 AM 7 sux.csv
    1 File(s) 7 bytes

    Why? Who knows? We're talking CP/M, MS-DOS and Windows and you want to
    know why? Probably too lazy to distinguish between 'AUX\0', 'AUX.\0'
    and 'AUX.XYZ\0' ... probably stopped scanning on reaching the first
    invalid character. If you're desperate to find out, dial up your
    nearest RCPM and ask the sysop :)

    Cheers,
    John
     
    John Machin, Feb 15, 2007
    #5
  6. En Thu, 15 Feb 2007 11:34:53 -0300, John Machin <>
    escribió:

    >> > Probably not. AUX, CON, NUL, PRN, LPT, COM1, COM2 etc (with or without
    >> > an extension) are reserved in Windows for specific devices for
    >> > compatibility with MS-DOS 1.00 programs, which did that for
    >> > compatibility with CP/M.

    >>
    >> (This is OT now) Do you know why "AUX.csv" is invalid too? I can accept
    >> that AUX (without extension) is an invalid filename, but it is quite
    >> different from "AUX.csv"
    >>

    >
    > It is actually a valid file name, but the file is not on disk. I
    > presume that the OP got an error because it was in 'a' (append) mode
    > which requires an existing disk file. See below.
    >
    > C:\junk>copy con aux.csv
    > fubar
    > ^Z
    > 1 file(s) copied.


    The above gives me an "Access denied" error; perhaps because AUX is my
    serial port and it is currently in use.

    > Why? Who knows? We're talking CP/M, MS-DOS and Windows and you want to
    > know why? Probably too lazy to distinguish between 'AUX\0', 'AUX.\0'
    > and 'AUX.XYZ\0' ... probably stopped scanning on reaching the first
    > invalid character. If you're desperate to find out, dial up your
    > nearest RCPM and ask the sysop :)


    Ahhhh... I think you hit the point, indirectly. On CP/M the filename was
    not stored as 'AUX\0' - remember, ONLY 8 characters plus 3 for extension,
    and NO PATH. A FileControlBlock (FCB) had exactly 11 characters reserved
    for the file name (plus the drive number). So it was actually "AUX
    " vs "AUX XYZ" and... well, the lazyness argument again.

    --
    Gabriel Genellina
     
    Gabriel Genellina, Feb 15, 2007
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mohammed  khader

    Simulation Error While writing to file

    Mohammed khader, Nov 24, 2004, in forum: VHDL
    Replies:
    3
    Views:
    1,580
    Jim Lewis
    Nov 30, 2004
  2. John Carnahan

    File Access error - writing to .txt file

    John Carnahan, Jul 18, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    817
    John Carnahan
    Jul 18, 2003
  3. HNguyen
    Replies:
    4
    Views:
    2,453
    HNguyen
    Dec 21, 2004
  4. Heiko Wundram

    sys.argv[0] and ps aux

    Heiko Wundram, May 15, 2004, in forum: Python
    Replies:
    1
    Views:
    353
    =?iso-8859-1?q?Nils_O=2E_Sel=E5sdal?=
    May 17, 2004
  5. Szabolcs Szucs

    exchange variables without aux. var...

    Szabolcs Szucs, Feb 8, 2007, in forum: C++
    Replies:
    13
    Views:
    703
    Grizlyk
    Feb 10, 2007
Loading...

Share This Page