Re: Fast forward-backward (write-read)

Discussion in 'Python' started by Tim Chase, Oct 23, 2012.

  1. Tim Chase

    Tim Chase Guest

    On 10/23/12 12:17, Virgil Stokes wrote:
    > On 23-Oct-2012 18:09, Tim Chase wrote:
    >>> Finally, to my question --- What is a fast way to write these
    >>> variables to an external file and then read them in
    >>> backwards?

    >> Am I missing something, or would the fairly-standard "tac"
    >> utility do the reversal you want? It should[*] be optimized to
    >> handle on-disk files in a smart manner.

    > Not sure about "tac" --- could you provide more details on this
    > and/or a simple example of how it could be used for fast reversed
    > "reading" of a data file?


    Well, if you're reading input.txt (and assuming it's one record per
    line, separated by newlines), you can just use

    tac < input.txt > backwards.txt

    which will create a secondary file that is the first file in reverse
    order. Your program can then process this secondary file in-order
    (which would be backwards from your source).

    I might have misunderstood your difficulty, but it _sounded_ like
    you just want to inverse the order of a file.

    -tkc
    Tim Chase, Oct 23, 2012
    #1
    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. Virgil Stokes

    Fast forward-backward (write-read)

    Virgil Stokes, Oct 23, 2012, in forum: Python
    Replies:
    7
    Views:
    142
    Virgil Stokes
    Oct 25, 2012
  2. Tim Chase
    Replies:
    0
    Views:
    171
    Tim Chase
    Oct 23, 2012
  3. Dennis Lee Bieber

    Re: Fast forward-backward (write-read)

    Dennis Lee Bieber, Oct 23, 2012, in forum: Python
    Replies:
    0
    Views:
    129
    Dennis Lee Bieber
    Oct 23, 2012
  4. Virgil Stokes

    Re: Fast forward-backward (write-read)

    Virgil Stokes, Oct 23, 2012, in forum: Python
    Replies:
    4
    Views:
    182
    Tim Golden
    Oct 24, 2012
  5. Virgil Stokes

    Re: Fast forward-backward (write-read)

    Virgil Stokes, Oct 23, 2012, in forum: Python
    Replies:
    0
    Views:
    107
    Virgil Stokes
    Oct 23, 2012
Loading...

Share This Page