How to delete a row in text file?

Reply

Join Date: Sep 2006
Posts: 54
Reputation: royaloba is an unknown quantity at this point 
Solved Threads: 1
royaloba royaloba is offline Offline
Junior Poster in Training

How to delete a row in text file?

 
1
  #1
Sep 11th, 2006
Hello to everyone, i have a project which base on text file. and i already know how to view the text file using a listbox, what i want to know is on how to delete a specific row in text file.. thanks
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: How to delete a row in text file?

 
0
  #2
Sep 11th, 2006
post an example of the textfile, and we can go from there. The concept is fairly simple, however. You open the text file, and while you are reading in all the contents, compare each line with whatever you are looking for (say, the persons social security number), and then if they do not match, add that line to a string (or to another, temp file), and if they DO match, simply don't add it to the new file (or the string variable).
Last edited by Comatose; Sep 11th, 2006 at 10:26 am.
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 54
Reputation: royaloba is an unknown quantity at this point 
Solved Threads: 1
royaloba royaloba is offline Offline
Junior Poster in Training

Re: How to delete a row in text file?

 
0
  #3
Sep 11th, 2006
2005/11/11 17:36:13, Event:Access, Door:entry, Card No.:1234, Description:333
2005/11/11 17:36:17, Event:Access, Door:entry, Card No.:1234, Description:333
2005/11/11 17:36:20, Event:Access, Door:entry, Card No.:2222, Description:222
2005/11/11 17:36:26, Event:Access, Door:entry, Card No.:2222, Description:222

hello sir this is the sample of the text file... would you please give me a code which can i delete a specific row... thanks Comatose
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: How to delete a row in text file?

 
0
  #4
Sep 11th, 2006
How are you going to decide which row? The user has a listbox, and the listbox has all this same information? Will they be deleting the row date, time, cardno or description?
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 54
Reputation: royaloba is an unknown quantity at this point 
Solved Threads: 1
royaloba royaloba is offline Offline
Junior Poster in Training

Re: How to delete a row in text file?

 
0
  #5
Sep 11th, 2006
thanks for your response.. my project is to create a time and attendance using a reader which the reader createss a textlog
like this

2005/11/11 13:32:45, EventIN Error, Door:entry, Description:201:44000
2005/11/11 13:39:58, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 13:39:59, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 13:40:03, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 13:40:26, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 13:40:28, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 13:48:58, Event:Card No. Error, Door:entry, Description:66:19157
2005/11/11 13:48:58, EventIN Error, Door:entry, Description:66:19157
2005/11/11 14:24:03, EventIN Error, Door:entry
2005/11/11 15:19:59, Event:Card No. Error, Door:entry, Description:66:19157
2005/11/11 15:20:03, EventIN Error, Door:entry, Description:66:19157
2005/11/11 15:20:05, EventIN Error, Door:entry, Description:66:19157
2005/11/11 15:20:50, Eventoor Group Error, Door:entry, Card No.:2229, Description:66:19157
2005/11/11 17:36:05, Eventoor Group Error, Door:entry, Card No.:2229, Description:66:19157
2005/11/11 17:36:13, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:36:17, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:36:20, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:36:26, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:36:41, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:36:45, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:36:51, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:37:19, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:37:36, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:37:45, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:37:54, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:38:11, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:38:20, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:39:40, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:41:04, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:43:51, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:50:58, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:51:11, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:51:44, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:52:31, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:52:47, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:52:55, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 17:53:31, Event:Access, Door:entry, Card No.:2345, Description:266:55732
2005/11/11 18:32:48, Eventassword Error, Door:entry, Card No.:1240
2005/11/11 18:35:32, Event:Access, Door:entry, Card No.:2271, Description:266:55250
2005/11/11 18:35:38, Event:Access, Door:entry, Card No.:2271, Description:266:55250
2005/11/11 18:36:01, Event:Access, Door:entry, Card No.:2271, Description:266:55250
2005/11/11 18:55:41, Event:Access, Door:entry, Card No.:2271, Description:266:55250
2005/11/11 18:57:41, Event:Access, Door:entry, Card No.:2271, Description:266:55250
2005/11/11 19:06:25, Event:Access, Door:entry, Card No.:2345, Description:266:55732

when i open this file in list box us you notice there is some text row that is diff. from the others. that specific row i want to delete because when i save this file in access if there is some row that are diff to the other is creates a error.. thanks
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: How to delete a row in text file?

 
0
  #6
Sep 11th, 2006
Can you define which ones should be removed? Anything that is not:
2005/11/11 17:50:58, Event:Access, Door:entry, Card No.:2345, Description:266:55732
Right?
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 54
Reputation: royaloba is an unknown quantity at this point 
Solved Threads: 1
royaloba royaloba is offline Offline
Junior Poster in Training

Re: How to delete a row in text file?

 
0
  #7
Sep 12th, 2006
yes sir, anything that not match the format

2005/11/11 17:50:58, Event:Access, Door:entry, Card No.:2345, Description:266:55732

thanks
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3,114
Reputation: WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of 
Solved Threads: 281
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Sensei

Re: How to delete a row in text file?

 
0
  #8
Sep 12th, 2006
Read each line
If it contains "Event:Access, Door:entry, Card No.", write it to the file
If not, don't
If not at end-of-file, go back to read the next line
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 54
Reputation: royaloba is an unknown quantity at this point 
Solved Threads: 1
royaloba royaloba is offline Offline
Junior Poster in Training

Re: How to delete a row in text file?

 
0
  #9
Sep 12th, 2006
thanks to your reply,but sir a want a sample code..thanks
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 3,114
Reputation: WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of WaltP has much to be proud of 
Solved Threads: 281
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Sensei

Re: How to delete a row in text file?

 
0
  #10
Sep 12th, 2006
Originally Posted by royaloba View Post
thanks to your reply,but sir a want a sample code..thanks
Please sir, first answer these questions:
1) do you know how to open a file?
2) Do you know how to read the file one line at a time?
3) Do you know how to check if a line (string) contains specific substring?

And finally
4) Are you trying to learn how to program, or have the program written for you?
The 3 Laws of the Procrastination Society:
1) Never do today that which can be put off until tomorrow
2) Tomorrow never comes
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC