Counting characters

Mar 3, 2009 at 5:54pm

Counting characters

Hi list,

I’m trying to count how many characters (including spaces, floats and semicolons) are in [coll]. Is there a way?

I’m getting close by using [spell] and [capture] and adding an approximation but it is far from ideal.

Any pointers would be greatly appreciated.

Thanks,
Andrew

#42644
Mar 3, 2009 at 6:59pm

Using strlen by Jasch you could do:

– Pasted Max Patch, click to expand. –

Best, Joerg

#152662
Mar 3, 2009 at 7:51pm
Andrew S wrote on Tue, 03 March 2009 18:54
Any pointers would be greatly appreciated.

That is probably silly but I would go for saving the coll file, and look at the size of the file.

#152663
Mar 3, 2009 at 8:06pm

I was thinking exactly the same as Emmanuel, but just in case you don’t want to have to store your [coll] contents you could try the method on the right side of this patch.

lh

– Pasted Max Patch, click to expand. –
#152664
Mar 3, 2009 at 8:33pm

Thanks for the replies.

Joerg, that is exactly what I was looking for.

Lh, your ‘copy compress’ isn’t reading for some reason… do you mind trying again?

I needed this process to happen “automatically” with no user input, which is why [strlen] works better for me then reading the file size.

Thanks again!

#152665
Mar 3, 2009 at 8:42pm

How odd, I’ll attach the file here as well then.

lh

#152666
Mar 3, 2009 at 10:39pm

Thanks for sending the file. It seems to be adding a few characters. I’m not sure why, or if it’s something I’m doing wrong but I’m OK using [strlen] for now, thank you.

#152667
Mar 3, 2009 at 10:44pm

It should count every character including punctuation, spaces and include the indices, the only thing it won’t count is newline characters, but if [strlen] is working for you then no worries!

lh

#152668
Mar 3, 2009 at 11:33pm

I have no idea, when I load some other files, it works. My lines in the coll look something like this:
f, 261 1 2 0.81 1.;

Could the letters at the beginning be the cause of it? When I have some more time, I’ll try figure out what I’m doing wrong. I’m pretty sure it’s on my side though, as I’m not used to working with [coll]

Thanks for all your help.

#152669
Mar 3, 2009 at 11:47pm

Ah it seems that it adds trailing zeros on to the floating point numbers and then counts all those zeros, oops!

lh

#152670
Mar 4, 2009 at 12:00am

That makes sense. Glad it’s demystified!

#152671

You must be logged in to reply to this topic.