Permission problem under WinXP

Discussion in 'Ruby' started by RichardOnRails, Nov 25, 2008.

  1. Hi All,

    I generated a Ruby on Rails app, which among other things, had to
    import content from a bunch of CSV files from time to time. When I
    generated the app, I had a typo: I used cvs instead of csv. When I
    started coding, I used csv. It got to be a mess. Being pigheaded I
    decided to write a ruby script to transform all file-names and file
    content to conform to csv.

    The transformation script is posted at http://www.pastie.org/323198.
    I've tested the code thoroughly, so I think its really a Windows
    problem: it's keeping a lock on the file(s) I'm using despite the
    fact that I issued Ruby close commands.

    I wonder if anyone has a quick fix for this problem. If not, I'll
    walk the extra mile and write my filename changes to disk and write a
    stand-alone app to apply those changes. But if there's a slick way to
    solves this, I'd like to learn it.

    Thanks in Advance,
    Richard
     
    RichardOnRails, Nov 25, 2008
    #1
    1. Advertising

  2. RichardOnRails wrote:
    > Hi All,
    >
    > I generated a Ruby on Rails app, which among other things, had to
    > import content from a bunch of CSV files from time to time. When I
    > generated the app, I had a typo: I used cvs instead of csv. When I
    > started coding, I used csv. It got to be a mess. Being pigheaded I
    > decided to write a ruby script to transform all file-names and file
    > content to conform to csv.
    >
    > The transformation script is posted at http://www.pastie.org/323198.
    > I've tested the code thoroughly, so I think its really a Windows
    > problem: it's keeping a lock on the file(s) I'm using despite the
    > fact that I issued Ruby close commands.
    >
    > I wonder if anyone has a quick fix for this problem. If not, I'll
    > walk the extra mile and write my filename changes to disk and write a
    > stand-alone app to apply those changes. But if there's a slick way to
    > solves this, I'd like to learn it.


    Line 26:

    data = File.open(name).readlines

    There's your open handle. Replace that with:

    IO.readlines(name)

    Regards,

    Dan
     
    Daniel Berger, Nov 25, 2008
    #2
    1. Advertising

  3. On Nov 24, 11:55 pm, Daniel Berger <> wrote:
    > RichardOnRails wrote:
    > > Hi All,

    >
    > > I generated a Ruby on Rails app, which among other things,  had to
    > > import content from a bunch of CSV files from time to time.  When I
    > > generated the app,  I had a typo: I used cvs instead of csv.  When I
    > > started coding,  I used csv.  It got to be a mess.  Being pigheaded I
    > > decided to write a ruby script to transform all file-names and file
    > > content to conform to csv.

    >
    > > The transformation script is posted athttp://www.pastie.org/323198.
    > > I've tested the code thoroughly, so I think its really a Windows
    > > problem:  it's keeping a lock on the file(s) I'm using despite the
    > > fact that I issued Ruby close commands.

    >
    > > I wonder if anyone has a quick fix for this problem.  If not,  I'll
    > > walk the extra mile and write my filename changes to disk and write a
    > > stand-alone app to apply those changes.  But if there's a slick way to
    > > solves this,  I'd like to learn it.

    >
    > Line 26:
    >
    > data = File.open(name).readlines
    >
    > There's your open handle. Replace that with:
    >
    > IO.readlines(name)
    >
    > Regards,
    >
    > Dan


    Hi Dan,

    I just wrote my son, for whom I'm writing this app, that I was
    hoping I'd get a magic bullet so that I didn't have to write my array
    of name-changes to disk, read them in in second program and copy in my
    change algorithm.

    > There's your open handle ...


    And there's my magic bullet. Now I have to apologize for falsely
    claiming that Windows was at fault :)

    Thank you very much for post such a neat solution.

    Best wishes,
    Richard
     
    RichardOnRails, Nov 25, 2008
    #3
  4. On Nov 24, 11:55 pm, Daniel Berger <> wrote:
    > RichardOnRails wrote:
    > > Hi All,

    >
    > > I generated a Ruby on Rails app, which among other things,  had to
    > > import content from a bunch of CSV files from time to time.  When I
    > > generated the app,  I had a typo: I used cvs instead of csv.  When I
    > > started coding,  I used csv.  It got to be a mess.  Being pigheaded I
    > > decided to write a ruby script to transform all file-names and file
    > > content to conform to csv.

    >
    > > The transformation script is posted athttp://www.pastie.org/323198.
    > > I've tested the code thoroughly, so I think its really a Windows
    > > problem:  it's keeping a lock on the file(s) I'm using despite the
    > > fact that I issued Ruby close commands.

    >
    > > I wonder if anyone has a quick fix for this problem.  If not,  I'll
    > > walk the extra mile and write my filename changes to disk and write a
    > > stand-alone app to apply those changes.  But if there's a slick way to
    > > solves this,  I'd like to learn it.

    >
    > Line 26:
    >
    > data = File.open(name).readlines
    >
    > There's your open handle. Replace that with:
    >
    > IO.readlines(name)
    >
    > Regards,
    >
    > Dan


    Hey Dan,

    Final word: It worked perfectly. Many thanks.

    Best wishes,
    Richard
     
    RichardOnRails, Nov 25, 2008
    #4
  5. RichardOnRails wrote:
    > On Nov 24, 11:55 pm, Daniel Berger <> wrote:
    >> RichardOnRails wrote:
    >>> Hi All,
    >>> I generated a Ruby on Rails app, which among other things, had to
    >>> import content from a bunch of CSV files from time to time. When I
    >>> generated the app, I had a typo: I used cvs instead of csv. When I
    >>> started coding, I used csv. It got to be a mess. Being pigheaded I
    >>> decided to write a ruby script to transform all file-names and file
    >>> content to conform to csv.
    >>> The transformation script is posted athttp://www.pastie.org/323198.
    >>> I've tested the code thoroughly, so I think its really a Windows
    >>> problem: it's keeping a lock on the file(s) I'm using despite the
    >>> fact that I issued Ruby close commands.
    >>> I wonder if anyone has a quick fix for this problem. If not, I'll
    >>> walk the extra mile and write my filename changes to disk and write a
    >>> stand-alone app to apply those changes. But if there's a slick way to
    >>> solves this, I'd like to learn it.

    >> Line 26:
    >>
    >> data = File.open(name).readlines
    >>
    >> There's your open handle. Replace that with:
    >>
    >> IO.readlines(name)
    >>
    >> Regards,
    >>
    >> Dan

    >
    > Hey Dan,
    >
    > Final word: It worked perfectly. Many thanks.


    Excellent, glad to hear it.

    Regards,

    Dan
     
    Daniel Berger, Nov 25, 2008
    #5
    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. Alexander Stojakovic

    Integrated Security under Win2K and WinXP

    Alexander Stojakovic, Jan 15, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    336
    Alexander Stojakovic
    Jan 15, 2004
  2. Piet71
    Replies:
    0
    Views:
    597
    Piet71
    Apr 9, 2006
  3. Ulf Meinhardt
    Replies:
    0
    Views:
    1,248
    Ulf Meinhardt
    May 10, 2006
  4. RichardOnRails

    Permission problem under WinXP

    RichardOnRails, Nov 25, 2008, in forum: Ruby
    Replies:
    0
    Views:
    86
    RichardOnRails
    Nov 25, 2008
  5. Ved Antani
    Replies:
    0
    Views:
    163
    Ved Antani
    Feb 4, 2005
Loading...

Share This Page