Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Huge file [modified]

Huge file [modified]

Scheduled Pinned Locked Moved C#
csharpwindows-adminquestion
8 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    abalfazl
    wrote on last edited by
    #1

    I want to read a very large files such az log files in IIS line by line with an especial format for each line (by c#),Which way or function do you recommand? -- modified at 11:37 Wednesday 19th July, 2006

    N S 2 Replies Last reply
    0
    • A abalfazl

      I want to read a very large files such az log files in IIS line by line with an especial format for each line (by c#),Which way or function do you recommand? -- modified at 11:37 Wednesday 19th July, 2006

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      StreamReader reader = new StreamReader("MyFile"); string strLine; while( (strLine = reader.ReadLine() ) != null ) { // do something }

      1 Reply Last reply
      0
      • A abalfazl

        I want to read a very large files such az log files in IIS line by line with an especial format for each line (by c#),Which way or function do you recommand? -- modified at 11:37 Wednesday 19th July, 2006

        S Offline
        S Offline
        Super Lloyd
        wrote on last edited by
        #3

        tail ? (download cygwin) or perhaps // warning, pseudo-code, if it doesn't compile => fix the code yourself static void Main(string[] args) { string line; using(StreamReader sr = new StreamReader(args[0])) while((line = sr.ReadLine()) != null) { Console.WriteLine(line); Console.ReadLine(); } }

        A 1 Reply Last reply
        0
        • S Super Lloyd

          tail ? (download cygwin) or perhaps // warning, pseudo-code, if it doesn't compile => fix the code yourself static void Main(string[] args) { string line; using(StreamReader sr = new StreamReader(args[0])) while((line = sr.ReadLine()) != null) { Console.WriteLine(line); Console.ReadLine(); } }

          A Offline
          A Offline
          abalfazl
          wrote on last edited by
          #4

          Hello first of all thanks for answer,So Fast! Look the problem is that these are huge file,Maybe 1G... The solution that you recommanded ,have problem of speed,I want a solution that read file faster. Thanks in advance

          E S 2 Replies Last reply
          0
          • A abalfazl

            Hello first of all thanks for answer,So Fast! Look the problem is that these are huge file,Maybe 1G... The solution that you recommanded ,have problem of speed,I want a solution that read file faster. Thanks in advance

            E Offline
            E Offline
            Ennis Ray Lynch Jr
            wrote on last edited by
            #5

            It is two parts, one you have to use a stream with a file so big because you do not have the memory to do otherwise. Secondly, if the file is not indexed your SOL. If it is indexed you can use any traversal algorithm to get the data you need. ( I did this technique with the national do not call list and it works fairly fast) Also, you may consider c++ if you just need speed. A man said to the universe: "Sir I exist!" "However," replied the Universe, "The fact has not created in me A sense of obligation." -- Stephen Crane

            D 1 Reply Last reply
            0
            • E Ennis Ray Lynch Jr

              It is two parts, one you have to use a stream with a file so big because you do not have the memory to do otherwise. Secondly, if the file is not indexed your SOL. If it is indexed you can use any traversal algorithm to get the data you need. ( I did this technique with the national do not call list and it works fairly fast) Also, you may consider c++ if you just need speed. A man said to the universe: "Sir I exist!" "However," replied the Universe, "The fact has not created in me A sense of obligation." -- Stephen Crane

              D Offline
              D Offline
              Dan Neely
              wrote on last edited by
              #6

              Ennis Ray Lynch, Jr. wrote:

              Also, you may consider c++ if you just need speed.

              I'm not sure how much that would help though. The filesystem would still be the bottleneck in performance.

              E 1 Reply Last reply
              0
              • D Dan Neely

                Ennis Ray Lynch, Jr. wrote:

                Also, you may consider c++ if you just need speed.

                I'm not sure how much that would help though. The filesystem would still be the bottleneck in performance.

                E Offline
                E Offline
                Ennis Ray Lynch Jr
                wrote on last edited by
                #7

                You can use memory mapping in C++ which will reduce the bottle neck for speed. A man said to the universe: "Sir I exist!" "However," replied the Universe, "The fact has not created in me A sense of obligation." -- Stephen Crane

                1 Reply Last reply
                0
                • A abalfazl

                  Hello first of all thanks for answer,So Fast! Look the problem is that these are huge file,Maybe 1G... The solution that you recommanded ,have problem of speed,I want a solution that read file faster. Thanks in advance

                  S Offline
                  S Offline
                  Super Lloyd
                  wrote on last edited by
                  #8

                  what is it you want to do? the question was: "I want to read a very large files" I told you how to read without memory problem. Now it can't read faster than you! Had the question be: "I am looking for a particular pattern" I might have added an automated search function..... But if you want to read it all, you've got to do it man!

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups