how to delete every other line in a text file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lneilson
    New Member
    • Nov 2008
    • 1

    #1

    how to delete every other line in a text file

    Hi
    below is a sample of the text file I need to import into excel I have used to bold type to show the usless part of the file I only need the lines with the time and the number, but the layout of the file makes it impossible for me to import it where I can use it. I am not a programmer but I have managed to muck together a vb6 program that suits my needs until they changed the format of the text file
    any ideas?

    thanks

    lneilson





    11/27/2008
    6:04 AM 07 09 12 15 22 24 26 27 33 35 36 37 38 55 57 61 68 70 73 74 1x
    481621 11/27/2008
    6:08 AM 01 02 04 05 07 16 18 31 40 45 47 50 59 61 62 63 71 75 76 79 1x
    481622 11/27/2008
    6:12 AM 06 08 10 13 17 20 22 30 33 36 38 47 49 50 55 57 61 69 70 75 2x
    481623 11/27/2008
    6:16 AM 04 15 21 22 26 32 33 39 42 44 50 60 62 63 64 65 66 70 71 76 2x
    481624 11/27/2008
    6:20 AM 01 06 07 08 14 16 17 19 26 27 32 33 40 46 48 49 56 66 76 78 1x
  • rpicilli
    New Member
    • Aug 2008
    • 77

    #2
    Originally posted by lneilson
    Hi
    below is a sample of the text file I need to import into excel I have used to bold type to show the usless part of the file I only need the lines with the time and the number, but the layout of the file makes it impossible for me to import it where I can use it. I am not a programmer but I have managed to muck together a vb6 program that suits my needs until they changed the format of the text file
    any ideas?

    thanks

    lneilson





    11/27/2008
    6:04 AM 07 09 12 15 22 24 26 27 33 35 36 37 38 55 57 61 68 70 73 74 1x
    481621 11/27/2008
    6:08 AM 01 02 04 05 07 16 18 31 40 45 47 50 59 61 62 63 71 75 76 79 1x
    481622 11/27/2008
    6:12 AM 06 08 10 13 17 20 22 30 33 36 38 47 49 50 55 57 61 69 70 75 2x
    481623 11/27/2008
    6:16 AM 04 15 21 22 26 32 33 39 42 44 50 60 62 63 64 65 66 70 71 76 2x
    481624 11/27/2008
    6:20 AM 01 06 07 08 14 16 17 19 26 27 32 33 40 46 48 49 56 66 76 78 1x
    You must open the file, read line by line, as I can see into the file, your date always starts on position 7 of each line that you wanto to catch up, rigth?

    That should be you key. Read the line and keep into a variable, lets say MyDate these positions. Something like

    [CODE]

    MyDate = LineRead.substr ing(lineread, 7, 10)

    [CODE]

    Verify if MyDate is realy a date.

    I hope this help you

    Rpicilli

    Comment

    • wakerunner
      New Member
      • Dec 2008
      • 2

      #3
      Code:
      FF% = freefile
      open "c:\originalfile.txt" for input as #FF%
      
      F2% = freefile
      open "c:\tempfile.txt" for output as #f2%
      
      do until eof(ff%)
      line input #ff, TmpLine$
      if a% =1 then
      print #f2%, TmpLIne$
      a% =0
      else
      a% =1
      end if
      loop
      
      close
      
      filecopy "c:\tempfile.txt", "c:\originalfile.txt" 
      kill "c:\tempfile.txt"

      Comment

      Working...