Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: How to copy a range of lines  (Read 11482 times)

0 Members and 1 Guest are viewing this topic.

bobk544

    Topic Starter


    Rookie

    How to copy a range of lines
    « on: March 04, 2013, 10:11:35 AM »
    Hello,

    I have a very large .txt file and i want to split it up into manageable file sizes which i will then convert to ".doc" files.

    So i'm wonderiing how i could lets say copy the 1st 100k to file1, the next 100k to file2?

    thanks for any pointers!
    bobk

    Salmon Trout

    • Guest
    Re: How to copy a range of lines
    « Reply #1 on: March 04, 2013, 10:41:27 AM »
    How many characters per line in the large text file?

    bobk544

      Topic Starter


      Rookie

      Re: How to copy a range of lines
      « Reply #2 on: March 04, 2013, 10:44:45 AM »
      There are 80 characters per line and 283+ million characters overall! thanks bk!

      Salmon Trout

      • Guest
      Re: How to copy a range of lines
      « Reply #3 on: March 04, 2013, 10:46:45 AM »
      Do you mean you want the split files to be 100 kilobytes in size?


      bobk544

        Topic Starter


        Rookie

        Re: How to copy a range of lines
        « Reply #4 on: March 04, 2013, 10:51:00 AM »
        ah well 80 characters * 100,000 lines would be what 800,000 characters, so would that 800 kilobytes maybe? or what would that be? not being to expert at the bit/byte calcualtions!

        Salmon Trout

        • Guest
        Re: How to copy a range of lines
        « Reply #5 on: March 04, 2013, 11:00:38 AM »
        Well, you wrote "So i'm wonderiing how i could lets say copy the 1st 100k to file1, the next 100k to file2?" and I wasn't sure if you meant "100k" as "100,000 lines" or its more usual computer meaning of 100 Kbytes.

        bobk544

          Topic Starter


          Rookie

          Re: How to copy a range of lines
          « Reply #6 on: March 04, 2013, 11:06:12 AM »
          oh yes ok i see what you mean, thanks for clarifying that!

          Salmon Trout

          • Guest
          Re: How to copy a range of lines
          « Reply #7 on: March 04, 2013, 11:09:18 AM »
          So which is it?

          bobk544

            Topic Starter


            Rookie

            Re: How to copy a range of lines
            « Reply #8 on: March 04, 2013, 11:11:55 AM »
            oh and sorry but i didn't think that i may be difficult to really test or simulate this huge .txt file so, maybe we could just test a small file with maybe 1000 lines or so? and obvioulsly i can just tweak the numbers maybe? thanks again Salmon :D

            bobk544

              Topic Starter


              Rookie

              Re: How to copy a range of lines
              « Reply #9 on: March 04, 2013, 11:14:06 AM »
              for "which is it" i was looking for 100k lines at 80 characters each line, but for test, we could use 1000 lines total and split that into 2 files of 500 lines each at 80 characters per line?

              Salmon Trout

              • Guest
              Re: How to copy a range of lines
              « Reply #10 on: March 04, 2013, 11:20:25 AM »
              I have created a text file with 10,000 numbered lines in it. I shall test with this. It is like this

              Quote
              [1] The quick brown fox jumped over the lazy dog.
              [2] The quick brown fox jumped over the lazy dog.
              [3] The quick brown fox jumped over the lazy dog.
              [4] The quick brown fox jumped over the lazy dog.
              [5] The quick brown fox jumped over the lazy dog.
              (lines removed)
              [9996] The quick brown fox jumped over the lazy dog.
              [9997] The quick brown fox jumped over the lazy dog.
              [9998] The quick brown fox jumped over the lazy dog.
              [9999] The quick brown fox jumped over the lazy dog.
              [10000] The quick brown fox jumped over the lazy dog.

              A question: is the large text file ordinary text like you find in a book, with all sorts of characters like < > & " etc? Does it contain blank lines? Because if either of these is true then a VBscript solution would be better and easier.

              bobk544

                Topic Starter


                Rookie

                Re: How to copy a range of lines
                « Reply #11 on: March 04, 2013, 11:26:35 AM »
                yes actually the big file is the contatenation of a bunch of software programs, ie documents, scripts, xml, so yes it will definitely contain all kinds of characters and blank lines ect, so you are saying that a vbscript woudl be a better approach?

                Salmon Trout

                • Guest
                Re: How to copy a range of lines
                « Reply #12 on: March 04, 2013, 11:31:24 AM »
                so you are saying that a vbscript woudl be a better approach?

                Yes, and you can run it from a batch, I shall show. As long as you are able to run cscript.exe you will be fine. Type cscript /? at the prompt and if you see this we are good to go

                Usage: CScript scriptname.extension [option...] [arguments...]

                Options:
                 //B         Batch mode: Suppresses script errors and prompts from displaying
                 //D         Enable Active Debugging
                 //E:engine  Use engine for executing script
                 //H:CScript Changes the default script host to CScript.exe
                 //H:WScript Changes the default script host to WScript.exe (default)
                 //I         Interactive mode (default, opposite of //B)
                 //Job:xxxx  Execute a WSF job
                 //Logo      Display logo (default)
                 //Nologo    Prevent logo display: No banner will be shown at execution time
                 //S         Save current command line options for this user
                 //T:nn      Time out in seconds:  Maximum time a script is permitted to run
                 //X         Execute script in debugger
                 //U         Use Unicode for redirected I/O from the console


                bobk544

                  Topic Starter


                  Rookie

                  Re: How to copy a range of lines
                  « Reply #13 on: March 04, 2013, 11:31:54 AM »
                  ok thanks very much for that advise and i'm now going to look into how to create a VBScript and i've written alot of UNIX scripts, but not many DOS oriented scripts, so if you have such a script that would be great!

                  Salmon Trout

                  • Guest
                  Re: How to copy a range of lines
                  « Reply #14 on: March 04, 2013, 11:33:16 AM »
                  ok thanks very much for that advise and i'm now going to look into how to create a VBScript and i've written alot of UNIX scripts, but not many DOS oriented scripts, so if you have such a script that would be great!

                  I am writing one right now.