pop line from file

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sinan Nalkaya

    #1

    pop line from file

    hello all,
    i searched and google long long time but couldnt find any result, i
    want pop the first line from file, i dont want to read all file
    contents because file is being updated from another proccess. even i
    couldnt realize its algorithm, thanks for any suggestion
  • Dylan Wilson

    #2
    Re: pop line from file

    Try open.readline()
    [color=blue][color=green][color=darkred]
    >>>help(open)[/color][/color][/color]
    ....

    Comment

    • Sybren Stuvel

      #3
      Re: pop line from file

      Sinan Nalkaya enlightened us with:[color=blue]
      > i searched and google long long time but couldnt find any result, i
      > want pop the first line from file, i dont want to read all file
      > contents because file is being updated from another proccess.[/color]

      So basically, what you want is some sort of on-disk FIFO queue, right?
      Unless your filesystem supports this, there is no way to do that
      programmaticall y.

      Removing the first line of a file without having to rewrite the entire
      file, requires the pointer to the beginning of the data of the file to
      be altered. Since this pointer usually consists of a block number, it
      is impossible to point to the new start, unless all lines in the file
      are exactly one block in length. This probably isn't the case.

      If you're working on a UNIX platform, you could use FIFO pipes, see
      'mkfifo'.

      Sybren
      --
      The problem with the world is stupidity. Not saying there should be a
      capital punishment for stupidity, but why don't we just take the
      safety labels off of everything and let the problem solve itself?
      Frank Zappa

      Comment

      • Atanas Banov

        #4
        Re: pop line from file

        Sybren Stuvel wrote:
        [color=blue]
        > If you're working on a UNIX platform, you could use FIFO pipes, see
        > 'mkfifo'.[/color]

        named pipes exist on windows, see win32pipe.Creat eNamedPipe

        Comment

        • Sinan Nalkaya

          #5
          Re: pop line from file

          i am unix platform, now searching for the mkfifo topics.
          thank you all.

          Comment

          Working...