CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2016
    Posts
    1

    Modify large text file

    I have large text file, I need to find specific value and replace it by given value.

    How do I do this by reading line by line and save to same text file
    (like notepad, or any other text editor does)

    Thanks in advance

    Leulae

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Modify large text file

    What do you consider "large text file"? How many MBs, GBs?

  3. #3
    Join Date
    Feb 2011
    Location
    United States
    Posts
    1,016

    Re: Modify large text file

    You can, of course, do this in C#, but you might consider using some GNU utilities under Linux or Cygwin (under Windows) to do it as a command-line one-liner, like:

    Code:
    cat mytextfile.txt | sed 's/regexToFind/replaceWith/g' > mytextfile_fixed.txt
    You can also do it with PowerShell on Windows, see e.g.: http://opensysblog.directorioc.net/2...owershell.html
    Best Regards,

    BioPhysEngr
    http://blog.biophysengr.net
    --
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured