#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    154
    Rep Power
    14

    Copying the contents of a file to a new file


    Well I've never come across such a wierd problem like this before. If I use the following four lines:

    Code:
    corpus_tagwords = open("taggedwords.txt","r")
    
    tempwords = corpus_tagwords.read()
    
    corpus_tagwords = open("corpustaggedwords.txt","w")
    
    corpus_tagwords.write(tempwords)
    in isolation as a complete program, then a text file with the exact number of lines as the original file 251326 lines is re-created.

    If however, I use these four lines in a much longer program e.g. 300+ lines, for some reason the file that is recreated only contains 250617 lines and even more interestingly, the last line is only partially complete/visible!!! No idea what could be causing this as I'm sure nothing in the rest of the long program is interfering with these variables.

    Has anybody else experienced this??? Any advice much appreciated.

    Mark
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    154
    Rep Power
    14
    Problem Resolved. Remember kids... Always keep track of what files you've opened and 'forgot' :-( to close, its the little details that count in the world of programming. That's what many hours plugging away at this program does to you!!!

IMN logo majestic logo threadwatch logo seochat tools logo