Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Reading and changing a text form

RonaldSRonaldS Posts: 33Member
How can I input a line, 1 line at a time, from a text file, make changes to that line, and save the changed line? The may be as many as 1000 lines in a file.

Comments

  • BitByBit_ThorBitByBit_Thor Posts: 2,444Member
    : How can I input a line, 1 line at a time, from a text file, make
    : changes to that line, and save the changed line? The may be as many
    : as 1000 lines in a file.

    I suggest either 1) Reading one line at a time, and saving to a temp output file one at a time. Then when you're done reading, close the file, remove it and change the name of the temp file to match the original, or 2) Read the entire file at once, modify each line, and then write the output back.
    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
Sign In or Register to comment.