How to edit a Text file in MAX?

#173189
Feb 1, 2010 at 4:53pm

How to edit a Text file in MAX?

Hi there

I would like to find a way to edit some text files automatically.
For example if I have this text in my text files, I want to extract the number in between “toilets” and “times”:

Text file 1:
“Robert has been to the toilets 200 times today”
result: “200″

Text file 2:
“Robert has been to the toilets 22 times today”
result: “22″

Anyone knows how to do that???
Many thanks

Jon

#48158
Feb 1, 2010 at 5:09pm

Since what you want to do isn’t really well described, I’d suggest that you take a look at the zl object [which would let you group, split, output and concatenate lists] or the route object [which will strip off something you watch for and pass the rest along] or the regexp objects [which will do all kinds of UNIX-style searche/replace operations].

Try looking at those objects as a start….

#173183
Feb 1, 2010 at 5:35pm

maybe this could help you…

– Pasted Max Patch, click to expand. –
#173184
Feb 1, 2010 at 5:51pm

Max is probably one of the worst tools for this job, after perhaps MS Paint. Have you thought about using some Javascript?

#173185
Feb 1, 2010 at 6:02pm

Thanks Gregory.
Sorry for not being too clear…..here is what I’d like to achieve:

I am using a text file generated from an URL page source (myspace page). I am trying to extract a data from this page source which is the number of profile views.
What I want to do is to be able to extract the number that is next to the “profile views” part in the text.

For example, I want to remove everything but the number “26563″ below, how do I do that?? :

bgcolor=”#ffffff” class=”text”>

yes it is yes it is yes it is oh yes it is

Leeds/LA/Grenoble/Northampton, London and South East

United Kingdom

Profile Views: 
26563

Last Login: 
01/02/2010

#173186
Feb 1, 2010 at 7:06pm

this would be my attempt to solve it.
but I still have the feeling that it isn’t the perfect way of doing it.

– Pasted Max Patch, click to expand. –
#173187
Feb 1, 2010 at 7:40pm

If you’re grabbing the source with [jit.uldl] then try something like this.

lh

– Pasted Max Patch, click to expand. –
#173188
Feb 1, 2010 at 8:51pm

many thanks I’m nearly there….the code is too long so It doesn’t seem to work…do you wanna have a try?





<br /> ENCHUFADA on MySpace Music – Free Streaming MP3s, Pictures & Music Videos<br />


Feb 1, 2010 at 9:00pm

Haha you only needed to post the link! The problem was the spaces between the “Profile Views:” and the actual number is a non-breaking space which in html is

#173190
Feb 1, 2010 at 9:02pm

thanks mate, yeah it works perfectly now!
Good work!!
Best wishes to all
Jon

#173191
Feb 1, 2010 at 9:20pm

the [text] object, some zl and some sprintf ist really all you need.

#173192

You must be logged in to reply to this topic.