[text-files] How do I read a text file of about 2 GB?

I have a .txt file whose memory is more than 2 GB. The problem is I cannot open it with Notepad, Notepad++ or any other editor programs.

Any solutions?

This question is related to text-files notepad++ openoffice-writer

The answer is


For reading and editing, Geany for Windows is another good option. I've run in to limit issues with Notepad++, but not yet with Geany.


If you only need to read the file, I can suggest Large Text File Viewer. https://www.portablefreeware.com/?id=693

and also refer this

Text editor to open big (giant, huge, large) text files

else if you would like to make your own tool try this . i presume that you know filestream reader in c#

const int kilobyte = 1024;
const int megabyte = 1024 * kilobyte;
const int gigabyte = 1024 * megabyte;

public void ReadAndProcessLargeFile(string theFilename, long whereToStartReading = 0)
{
    FileStream fileStream = new FileStream(theFilename, FileMode.Open, FileAccess.Read);
    using (fileStream)
    {
        byte[] buffer = new byte[gigabyte];
        fileStream.Seek(whereToStartReading, SeekOrigin.Begin);
        int bytesRead = fileStream.Read(buffer, 0, buffer.Length);
        while(bytesRead > 0)
        {
            ProcessChunk(buffer, bytesRead);
            bytesRead = fileStream.Read(buffer, 0, buffer.Length);
        }
    }
}

private void ProcessChunk(byte[] buffer, int bytesRead)
{
    // Do the processing here
}

refer this kindly

http://www.codeproject.com/Questions/543821/ReadplusBytesplusfromplusLargeplusBinaryplusfilepl


Try Vim, emacs (has a low maximum buffer size limit if compiled in 32-bit mode), hex tools


Instead of loading / reading the complete file, you could use a tool to split the text file in smaller chunks. If you're using Linux, you could just use the split command (see this stackoverflow thread). For Windows, there are several tools available like HJSplit (see this superuser thread).


I use UltraEdit to edit large files. The maximum size I open with UltraEdit was about 2.5 GB. Also UltraEdit has a good hex editor in comparison to Notepad++.


WordPad will open any text file no matter the size. However, it has limited capabilities as compared to a text editor.


EmEditor works quite well for me. It's shareware IIRC but doesn't stop working after the license expires..


I always use 010 Editor to open huge files. It can handle 2 GB easily. I was manipulating files with 50 GB with 010 Editor :-)

It's commercial now, but it has a trial version.


There are quite number of tools available for viewing large files. http://download.cnet.com/Large-Text-File-Viewer/3000-2379_4-90541.html This for instance. However, I was successful with larger files viewing in Visual studio. Thought it took some time to load, it worked.