topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 4:05 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: Delete lines starting with a string in a txt file predefined  (Read 13075 times)

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Delete lines starting with a string in a txt file predefined

i have been searching an app for delete lines beginning with a string of any kind previosly proposed.
I have found more o less complicated answer for me in Linux and other environments.

Exist a tool for dummies ?

Best Regards
 :-*

ejem. A tool for windows 7-64
 :-[

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Delete lines starting with a string in a txt file predefined
« Reply #1 on: January 26, 2014, 11:58 AM »
Contro we are going to have to start making a rule for you about the # of requests you can post per day  :o

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: Delete lines starting with a string in a txt file predefined
« Reply #2 on: January 26, 2014, 12:05 PM »
Contro we are going to have to start making a rule for you about the # of requests you can post per day  :o

Understood. How many ?

http://i126.photobucket.com/albums/p108/random17_bucket/emoticons.jpg
Delete lines starting with a string in a txt file predefined

 :-[

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,286
    • View Profile
    • Donate to Member
Re: Delete lines starting with a string in a txt file predefined
« Reply #3 on: January 26, 2014, 12:46 PM »
Contro, you really ought to try Text Monkey Pro.  It's not free ($30) but it can do all sorts of things to text files including the thing you mention in this post and many that you've mentioned in the past.

http://www.boxersoftware.com/tmfeat.htm

In the "Line Operations" section, there is a "Delete lines that contain user-specified text" option that should cover your need expressed in this thread.

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: Delete lines starting with a string in a txt file predefined
« Reply #4 on: January 26, 2014, 01:21 PM »
Contro, you really ought to try Text Monkey Pro.  It's not free ($30) but it can do all sorts of things to text files including the thing you mention in this post and many that you've mentioned in the past.

http://www.boxersoftware.com/tmfeat.htm

In the "Line Operations" section, there is a "Delete lines that contain user-specified text" option that should cover your need expressed in this thread.

 :-* Running to try

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: Delete lines starting with a string in a txt file predefined
« Reply #5 on: January 26, 2014, 03:31 PM »
Please wait for me.
It's almost done, but i have a little error and have to depure.


Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: Delete lines starting with a string in a txt file predefined
« Reply #6 on: January 26, 2014, 03:55 PM »
Done !!!!!!!!!!

I think is well done. In English. Someone to try ?
 :-*

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: Delete lines starting with a string in a txt file predefined
« Reply #7 on: January 26, 2014, 03:57 PM »
I am interested in other options like favorite for firefox, etc.

 ;D

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: Delete lines starting with a string in a txt file predefined
« Reply #8 on: January 26, 2014, 04:01 PM »
sorry. these answers go in the other post.....

https://www.donation...?topic=37083.new#new
 :-[

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: Delete lines starting with a string in a txt file predefined
« Reply #9 on: January 26, 2014, 04:37 PM »
Contro, you really ought to try Text Monkey Pro.  It's not free ($30) but it can do all sorts of things to text files including the thing you mention in this post and many that you've mentioned in the past.

http://www.boxersoftware.com/tmfeat.htm

In the "Line Operations" section, there is a "Delete lines that contain user-specified text" option that should cover your need expressed in this thread.

 :-* Running to try


I am trying, but is not exactly to extract the beginning lines with <String>, instead lines containing a <string> is the target with Text Monkey (There is a lite version too)
but finally i obtain the lines, but now I have to elliminate every first characters of any residual line . How can i do that now ?
the first characters of every line are not the same.
Are the 12 first characters of any line.
 :-*

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: Delete lines starting with a string in a txt file predefined
« Reply #10 on: January 26, 2014, 04:58 PM »
I have found something may help. And perhaps a macro with pspad is enough

:

Home
Delete Delete Delete
Down
Home
Delete Delete Delete
Down
Home
Delete Delete Delete


or something similar may serve. But I don't remember how. But i create a macro in pspad yesterday. Damn memory !!!!!!!!!!!!!!!!!
 >:(

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: Delete lines starting with a string in a txt file predefined
« Reply #11 on: January 26, 2014, 05:31 PM »
 ;D
done .
The code with pspad is something like this

ecDeleteChar
ecDeleteChar
ecDeleteChar
ecDeleteChar
ecDeleteChar
ecDeleteChar
ecDeleteChar
ecDeleteChar
ecDeleteChar
ecDeleteChar
ecDeleteChar
ecDeleteChar
ecDeleteChar
ecDown

Beginning from the line we want to remove the first 13 characters.
"As usual" is enough to repeat the macro to remove the second line
and so on.
 :-*

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: Delete lines starting with a string in a txt file predefined
« Reply #12 on: January 26, 2014, 11:59 PM »
throwing my hat into DoCo's favourite past-time. :-\

@Contro: since you mentioned PSPad, there is a way to do what you wanted (or at least what i *think* you wanted) within PSPad.

1. Open the text file in PSPad.
2. Press Control + F to open the 'Find' dialog.
3. Type the "predefined" string.
4. Click "Copy non-matching" (see attached image).
5. Click the "Copy" button.
6. PSPad will open a *new* text file without the "predefined" string that you didn't want.
7. Now you just have to save it.

Attached image: PSPad Find Dialog
Spoiler


Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: Delete lines starting with a string in a txt file predefined
« Reply #13 on: January 27, 2014, 06:52 AM »
throwing my hat into DoCo's favourite past-time. :-\

@Contro: since you mentioned PSPad, there is a way to do what you wanted (or at least what i *think* you wanted) within PSPad.

1. Open the text file in PSPad.
2. Press Control + F to open the 'Find' dialog.
3. Type the "predefined" string.
4. Click "Copy non-matching" (see attached image).
5. Click the "Copy" button.
6. PSPad will open a *new* text file without the "predefined" string that you didn't want.
7. Now you just have to save it.

Attached image: PSPad Find Dialog

Yes. But seems don't delete the entire line that contains the string, or mantain if is the case.
 :-*

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: Delete lines starting with a string in a txt file predefined
« Reply #14 on: January 27, 2014, 06:59 AM »
Yes. But seems don't delete the entire line that contains the string, or mantain if is the case.
 :-*
can you post a screenshot of these lines? maybe that could give a clue as to why they are not being deleted.

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: Delete lines starting with a string in a txt file predefined
« Reply #15 on: January 27, 2014, 07:10 AM »
Yes. But seems don't delete the entire line that contains the string, or mantain if is the case.
 :-*
can you post a screenshot of these lines? maybe that could give a clue as to why they are not being deleted.
forgive me lanux128. I haven't tried. It just a thought the line will not be removed. The line contains the string, but you said that only the string will be removed in the copied file.
 :-[

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: Delete lines starting with a string in a txt file predefined
« Reply #16 on: January 27, 2014, 07:21 AM »
forgive me lanux128. I haven't tried. It just a thought the line will not be removed. The line contains the string, but you said that only the string will be removed in the copied file.
 :-[
go ahead and try the method i have outlined. the beauty of this solution is that it wouldn't touch the original file so you can do a diff and see if the lines that you wanted gone are truly gone.

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: Delete lines starting with a string in a txt file predefined
« Reply #17 on: January 27, 2014, 05:54 PM »
 :-*
I am here again.
I have made exhaustive proofs because I don't was very convinced of the problem to solve.
But really PSPAD, under the conditions expressed by Lanux128 delete the entire line.
Consider this example :
dermatitis es la enfermedad
dermatitis es una enfermedad
la dermatitis es una enfermedad
la enfermedad conocida como dermatitis
una enfermedad conocida como dermatitis produce sufrimiento por la picazón

I want to delete all the lines that begins with "dermatitis" without quotes.
But the effect is that all the lines are deleted.....

But the point or interesting effect of this experiment is the PSpad interpretation of delete the entire line because we can't initially supposed that pspad will delete the entire line is simple encounter the string inside that line in any position.

I remember my wonderful dBASE III and the commands trim() ,left trim() , right trim() , substring() and so on. (Please I don't remember exactly, but I think was something similar). With those functions i can manipulate strings.

 :P

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: Delete lines starting with a string in a txt file predefined
« Reply #18 on: January 27, 2014, 05:57 PM »
So the conclusion is :

The above example is useful to delete all the lines that contains a predefined String
 :-*

skwire

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,286
    • View Profile
    • Donate to Member
Re: Delete lines starting with a string in a txt file predefined
« Reply #19 on: January 27, 2014, 06:48 PM »
I want to delete all the lines that begins with "dermatitis" without quotes.
But the effect is that all the lines are deleted.....

Follow lanux128's steps but check the "Regular Expressions" box and use this as a search string: ^dermatitis

2014-01-27_184749.jpgDelete lines starting with a string in a txt file predefined
« Last Edit: January 27, 2014, 07:35 PM by skwire »

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: Delete lines starting with a string in a txt file predefined
« Reply #20 on: January 28, 2014, 02:25 PM »
I want to delete all the lines that begins with "dermatitis" without quotes.
But the effect is that all the lines are deleted.....

Follow lanux128's steps but check the "Regular Expressions" box and use this as a search string: ^dermatitis
 (see attachment in previous post)

Understood. So seems we have a powerful "hidden" script maker with pspad.
I am charmed with the scripts to deleted x characters from any line selected (or repeating the script in many lines....)
 :-*

Contro

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 3,940
    • View Profile
    • Donate to Member
Re: Delete lines starting with a string in a txt file predefined
« Reply #21 on: January 28, 2014, 02:32 PM »
Beatiful indeed. Thanks both of you very much.
After some knowledge of regex i am convinced is for good professionals like yours.

Best Regards
 :tellme: :tellme: :tellme: :tellme:

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: Delete lines starting with a string in a txt file predefined
« Reply #22 on: January 29, 2014, 03:58 AM »
Beatiful indeed. Thanks both of you very much.
After some knowledge of regex i am convinced is for good professionals like yours.

well, i am glad to be of help and i am sure skwire's pretty chuffed about it too.  :Thmbsup: