473,320 Members | 1,939 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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
Nov 29 '08 #1
2 4654
@lneilson
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.substring(lineread, 7, 10)

[code]

Verify if MyDate is realy a date.

I hope this help you

Rpicilli
Nov 30 '08 #2
Expand|Select|Wrap|Line Numbers
  1. FF% = freefile
  2. open "c:\originalfile.txt" for input as #FF%
  3.  
  4. F2% = freefile
  5. open "c:\tempfile.txt" for output as #f2%
  6.  
  7. do until eof(ff%)
  8. line input #ff, TmpLine$
  9. if a% =1 then
  10. print #f2%, TmpLIne$
  11. a% =0
  12. else
  13. a% =1
  14. end if
  15. loop
  16.  
  17. close
  18.  
  19. filecopy "c:\tempfile.txt", "c:\originalfile.txt" 
  20. kill "c:\tempfile.txt"
Dec 10 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Robert Schneider | last post by:
Hi to all, I don't understand that: I try to delete a record via JDBC. But I always get the error SQL7008 with the error code 3. It seems that this has something to do with journaling, since the...
8
by: Dong Ge | last post by:
Hi! I am a beginner of C. I want to delete some characters or a whole line in a text file. I have tried the "fprintf", "fputs", "fwrite", but no one of them can run rightly. In the below...
5
by: ad | last post by:
I want to delete some text which begin with <!DOCTYPE and end with > in a file. How can I do it?
6
by: tomtown.net | last post by:
Hello I'm trying to get a single line removed from a text file using a search pattern (pretty simple: if line contains "NODE1") -> remove line). To achieve this I's like to operate with only the...
22
by: Cylix | last post by:
I have a 4row x 1col table, I would like to drop all the content of row three. Since Mac IE5.2 does not suppport deleteRow method, I have also try to set the innerHTML=''; but it does not work. ...
3
by: Arpan | last post by:
A Form has a FileUpload, 2 Buttons & a TextBox web server controls. Using the FileUpload control, I want to give users the provision to move & delete files that DO NOT exist in C:\Inetpub\wwwroot...
2
by: cdun2 | last post by:
Hello, I have some code that reads each line of a text file, and if a line is found where the length of the string in the line is 384, it writes the line to a text file. The other step that I...
4
by: jeepers | last post by:
Hi all, my problem is delete a line in a text file. the file contain -n line with user, userCode. i want to replace the line with user is egual at user, and/or insert new line but delete the...
10
by: Joah Senegal | last post by:
Hello all, I want something that should be realy really simple.... but I dont get it.. searched google and stuf, but found nothing useful. I;m opening a txt-file with a fstream. Now I want to...
29
by: shivasusan | last post by:
Hi! I can add rows with inputs to my HTML table dynamically using DOM, but I cannot remove selected rows. In fact, every row contains a Delete button. So, user selects the rows to remove, clicks...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.