How to delete row from text file?

Can I search a 800Meg text file for a specific piece of text, then delete all lines after that text?

  • Either delete all lines after the text and save the file or save the text from line 1 to the specific piece of text into a new file. I would like to do this using a program on windows (sed or awk) ?

  • Answer:

    That doesn't seem too hard, but not knowing the language you are using I can't really give you any specifics. I would just read through the file line by line (using some getLine() function), then search each line for the text you are looking for. After finding it, I guess it's personal preference how you want to save it. Either way seems equally efficient to me. That's about all I can offer you (I'm not a professional or anything, heh), but I hope that at least points you in the right direction. Consult your programming language's specific documentation to get a better idea (unless you are using the MSDN library - good luck getting any useful info out of that).

asims at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

try using efficient string searching algorithms http://en.wikipedia.org/wiki/String_searching_algorithm

Pierre T

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.