How to read large text file on windows? [closed]

2019-01-21 06:38发布

I have a large server log file (~750 MB) which I can't open with either Notepad or Notepad++ (they both say the file is too large).

Can anyone suggest a program (for Windows) that will only read a small part of the file into memory at a time?

Or do I need to write my own app to parse this file?

14条回答
女痞
2楼-- · 2019-01-21 06:42

if you can code, write a console app. here is the c# equivalent of what you're after. you can do what you want with the results (split, execute etc):

SqlCommand command = null;
try
{
    using (var connection = new SqlConnection("XXXX"))
    {
        command = new SqlCommand();
        command.Connection = connection;
        if (command.Connection.State == ConnectionState.Closed) command.Connection.Open();
        // Create an instance of StreamReader to read from a file.
        // The using statement also closes the StreamReader.
        using (StreamReader sr = new StreamReader("C:\\test.txt"))
        {
            String line;
            // Read and display lines from the file until the end of 
            // the file is reached.
            while ((line = sr.ReadLine()) != null)
            {
                Console.WriteLine(line);
                command.CommandText = line;
                command.ExecuteNonQuery();
                Console.Write(" - DONE");
            }
        }
    }
}
catch (Exception e)
{
    // Let the user know what went wrong.
    Console.WriteLine("The file could not be read:");
    Console.WriteLine(e.Message);
}
finally
{
    if (command.Connection.State == ConnectionState.Open) command.Connection.Close();
}
查看更多
3楼-- · 2019-01-21 06:44

If all you need is a tool for reading, then this thing will open the file instantly http://www.readfileonline.com/

查看更多
可以哭但决不认输i
4楼-- · 2019-01-21 06:45

try this...

Large Text File Viewer

By the way, it is free :)

But, I think you should ask this on serverfault.com instead

查看更多
▲ chillily
5楼-- · 2019-01-21 06:46

use EmEditor, it's pretty good, i used it to open a file with more than 500mb

查看更多
虎瘦雄心在
6楼-- · 2019-01-21 06:49

GnuUtils for Windows make this easy as well. In that package are standard UNIX utils like cat, ls and more. I am using cat filename | more to page through a huge file that Notepad++ can't open at all.

查看更多
登录 后发表回答