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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. READ TEXT FILE LINE BY LINE AND STORE ALL LINES IN ARRAY...(is a good idea?)

READ TEXT FILE LINE BY LINE AND STORE ALL LINES IN ARRAY...(is a good idea?)

Scheduled Pinned Locked Moved Visual Basic
data-structuresquestion
9 Posts 5 Posters 2 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.
  • S Offline
    S Offline
    sal21
    wrote on last edited by
    #1

    Ho to reading txt file line by line and store all lines in array. After all line are stored in array, loop in this array line by line for next use... You must know: 1- the dimension of text file is 163.457 MB 2- all line have max 132 lenght string 3 - into file is possible to have a blank line from one line to next line I hope and think is the best way to import this BIG file... I have count the lines are approx 3.364.120 lines!!!!!!!!!!!!!!!

    P L J 3 Replies Last reply
    0
    • S sal21

      Ho to reading txt file line by line and store all lines in array. After all line are stored in array, loop in this array line by line for next use... You must know: 1- the dimension of text file is 163.457 MB 2- all line have max 132 lenght string 3 - into file is possible to have a blank line from one line to next line I hope and think is the best way to import this BIG file... I have count the lines are approx 3.364.120 lines!!!!!!!!!!!!!!!

      P Offline
      P Offline
      Paul Conrad
      wrote on last edited by
      #2

      Need a little more clarification. What is the requirement for having all of the lines stored in an array? What are you trying to do with all of the lines once they've been read in?

      "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham

      S 1 Reply Last reply
      0
      • P Paul Conrad

        Need a little more clarification. What is the requirement for having all of the lines stored in an array? What are you trying to do with all of the lines once they've been read in?

        "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham

        S Offline
        S Offline
        sal21
        wrote on last edited by
        #3

        ok... i want to get a part of single line with MID,LEFT,RIGHT ecc and store the piece of line in a var. About array mode, is simple one suggestion.. in Google i have seen with FSO is a good way to speed the reading or not?

        G 1 Reply Last reply
        0
        • S sal21

          ok... i want to get a part of single line with MID,LEFT,RIGHT ecc and store the piece of line in a var. About array mode, is simple one suggestion.. in Google i have seen with FSO is a good way to speed the reading or not?

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          I, like Paul, still wonder why you need all the lines in an array? Do you really need all the lines in memory at once?

          sal21 wrote:

          in Google i have seen with FSO is a good way to speed the reading or not?

          FSO? Are you using VB6?

          Despite everything, the person most likely to be fooling you next is yourself.

          P 1 Reply Last reply
          0
          • S sal21

            Ho to reading txt file line by line and store all lines in array. After all line are stored in array, loop in this array line by line for next use... You must know: 1- the dimension of text file is 163.457 MB 2- all line have max 132 lenght string 3 - into file is possible to have a blank line from one line to next line I hope and think is the best way to import this BIG file... I have count the lines are approx 3.364.120 lines!!!!!!!!!!!!!!!

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            Hi,

            sal21 wrote:

            is a good idea?

            No! File.ReadAllLines will read the file and give you the huge array you are looking for; however generating such a huge array will be detrimental to the performance of your app, no matter how you do it. If a single pass through the file is all you need, have a look at streams. If you only need a fraction of the file's content, read it line by line, don't store all the lines, simply store the pieces you need (use StreamReader.ReadLine) :)

            Luc Pattyn [Forum Guidelines] [My Articles]


            Fixturized forever. :confused:


            1 Reply Last reply
            0
            • G Guffa

              I, like Paul, still wonder why you need all the lines in an array? Do you really need all the lines in memory at once?

              sal21 wrote:

              in Google i have seen with FSO is a good way to speed the reading or not?

              FSO? Are you using VB6?

              Despite everything, the person most likely to be fooling you next is yourself.

              P Offline
              P Offline
              Paul Conrad
              wrote on last edited by
              #6

              Guffa wrote:

              Do you really need all the lines in memory at once?

              I am still waiting for a real answer to that question I asked him. His requirements still make little sense other than picking off pieces of the text, but why everything all at once?

              "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham

              J 1 Reply Last reply
              0
              • S sal21

                Ho to reading txt file line by line and store all lines in array. After all line are stored in array, loop in this array line by line for next use... You must know: 1- the dimension of text file is 163.457 MB 2- all line have max 132 lenght string 3 - into file is possible to have a blank line from one line to next line I hope and think is the best way to import this BIG file... I have count the lines are approx 3.364.120 lines!!!!!!!!!!!!!!!

                J Offline
                J Offline
                Jon_Boy
                wrote on last edited by
                #7

                sal21 wrote:

                I hope and think is the best way to import this BIG file...

                When you say "import", what *exactly* are you implying. Are we talking just getting the data from the file into your app to use variables/collections of some kind. Then I would agree with the above, that using a streamreader and reading line by line would be the best bet. OR, if your goal is to get this data into a DB like SQL? If this is the case, I would scrap what you're doing an look into DTS/SSIS since both give you programmatic control of the data coming in and format/manipulate as needed. Speed wise, there's not even a comparison.

                Any suggestions, ideas, or 'constructive criticism' are always welcome. "There's no such thing as a stupid question, only stupid people." - Mr. Garrison

                1 Reply Last reply
                0
                • P Paul Conrad

                  Guffa wrote:

                  Do you really need all the lines in memory at once?

                  I am still waiting for a real answer to that question I asked him. His requirements still make little sense other than picking off pieces of the text, but why everything all at once?

                  "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham

                  J Offline
                  J Offline
                  Jon_Boy
                  wrote on last edited by
                  #8

                  Paul Conrad wrote:

                  I am still waiting for a real answer to that question I asked him.

                  To benchmark how fast the memory can be filled?

                  Any suggestions, ideas, or 'constructive criticism' are always welcome. "There's no such thing as a stupid question, only stupid people." - Mr. Garrison

                  P 1 Reply Last reply
                  0
                  • J Jon_Boy

                    Paul Conrad wrote:

                    I am still waiting for a real answer to that question I asked him.

                    To benchmark how fast the memory can be filled?

                    Any suggestions, ideas, or 'constructive criticism' are always welcome. "There's no such thing as a stupid question, only stupid people." - Mr. Garrison

                    P Offline
                    P Offline
                    Paul Conrad
                    wrote on last edited by
                    #9

                    :laugh: More along the lines of what is the purpose of reading the entire file into memory at once.

                    "The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon "Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham

                    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