DonationCoder.com Forum

Main Area and Open Discussion => General Software Discussion => Topic started by: Contro on January 26, 2014, 11:52 AM

Title: Delete lines starting with a string in a txt file predefined
Post by: Contro on January 26, 2014, 11:52 AM
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
 :-[
Title: Re: Delete lines starting with a string in a txt file predefined
Post by: mouser 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
Title: Re: Delete lines starting with a string in a txt file predefined
Post by: Contro 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)
 :-[
Title: Re: Delete lines starting with a string in a txt file predefined
Post by: skwire 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.
Title: Re: Delete lines starting with a string in a txt file predefined
Post by: Contro 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
Title: Re: Delete lines starting with a string in a txt file predefined
Post by: Contro 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.

Title: Re: Delete lines starting with a string in a txt file predefined
Post by: Contro on January 26, 2014, 03:55 PM
Done !!!!!!!!!!

I think is well done. In English. Someone to try ?
 :-*
Title: Re: Delete lines starting with a string in a txt file predefined
Post by: Contro on January 26, 2014, 03:57 PM
I am interested in other options like favorite for firefox, etc.

 ;D
Title: Re: Delete lines starting with a string in a txt file predefined
Post by: Contro on January 26, 2014, 04:01 PM
sorry. these answers go in the other post.....

https://www.donationcoder.com/forum/index.php?topic=37083.new#new
 :-[
Title: Re: Delete lines starting with a string in a txt file predefined
Post by: Contro 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.
 :-*
Title: Re: Delete lines starting with a string in a txt file predefined
Post by: Contro 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 !!!!!!!!!!!!!!!!!
 >:(
Title: Re: Delete lines starting with a string in a txt file predefined
Post by: Contro 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.
 :-*
Title: Re: Delete lines starting with a string in a txt file predefined
Post by: lanux128 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
(http://i.imgur.com/zcgc6W6.png)

Title: Re: Delete lines starting with a string in a txt file predefined
Post by: Contro 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.
 :-*
Title: Re: Delete lines starting with a string in a txt file predefined
Post by: lanux128 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.
Title: Re: Delete lines starting with a string in a txt file predefined
Post by: Contro 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.
 :-[
Title: Re: Delete lines starting with a string in a txt file predefined
Post by: lanux128 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.
Title: Re: Delete lines starting with a string in a txt file predefined
Post by: Contro 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
Title: Re: Delete lines starting with a string in a txt file predefined
Post by: Contro 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
 :-*
Title: Re: Delete lines starting with a string in a txt file predefined
Post by: skwire 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

[ You are not allowed to view attachments ]
Title: Re: Delete lines starting with a string in a txt file predefined
Post by: Contro 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 (https://www.donationcoder.com/forum/index.php?topic=37085.msg347863#msg347863))

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....)
 :-*
Title: Re: Delete lines starting with a string in a txt file predefined
Post by: Contro 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:
Title: Re: Delete lines starting with a string in a txt file predefined
Post by: lanux128 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: