Source language: Translate to:

Remove blank lines and duplicates

General questions about NeoBook

Moderator: Neosoft Support

Remove blank lines and duplicates

Postby stu » Tue Jul 22, 2014 9:11 pm

Im trying to parse some text and I have a few functions missing, one is to remove empty lines and the other one remove duplicates...

Eg:

Code: Select all
Christian
Marcus
Adrian
Adrian

Gale
Christian

Donovan
Gale


Will become:

Code: Select all
Christian
Marcus
Adrian
Gale
Donovan


Also, anyway to Uppercase?

Cheers.
User avatar
stu
 
Posts: 320
Joined: Wed Aug 07, 2013 11:37 am

Re: Remove blank lines and duplicates

Postby mishem » Tue Jul 22, 2014 11:06 pm

Code: Select all
StrReplace "[Text]" "[#13][#10][#13][#10]" "[#13]" "[Text]" ""
StrReplace "[Text]" "[#13][#13]" "[#13]" "[Text]" ""

StrParse "[Text]" "[#13]" "[Text]" "[number]"

Loop "1" "[number]" "[i]"
    SearchStr "[Text[i]]" "[Temp]" "[Result]" ""
    If "[Result]" "=" "0"
        If "[i]" "=" "1"
            SetVar "[Temp]" "[Text[i]]"
        Else
            SetVar "[Temp]" "[Temp][#13][Text[i]]"
        EndIf
    EndIf
EndLoop

StrUpper "[Temp]" "[Text]"

.SetVar "[Text]" "[Temp]"

DeleteArray "[Text]" "All"
ClearVariables "[Result],[Temp]"
mishem
 
Posts: 575
Joined: Mon Oct 08, 2012 1:51 pm

Re: Remove blank lines and duplicates

Postby dpayer » Wed Jul 23, 2014 7:19 am

stu wrote:Im trying to parse some text and I have a few functions missing, one is to remove empty lines and the other one remove duplicates...
Cheers.


If this list is used in a listbox, you may want to try the function I created here (Advanced Listbox)

One of the processes provided is to remove duplicates. Maybe the code will give you some ideas.

David P.
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1383
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Re: Remove blank lines and duplicates

Postby stu » Fri Jul 25, 2014 9:30 pm

thanks for the answers, I tried mishem's method and works pretty good but still misses some duplicates, I'll give a go to the Listbox option.

Greetings.
User avatar
stu
 
Posts: 320
Joined: Wed Aug 07, 2013 11:37 am


Return to General NeoBook Discussions

Who is online

Users browsing this forum: No registered users and 3 guests