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
Using strlen by Jasch you could do:
Best, Joerg
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.
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
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!
How odd, I'll attach the file here as well then.
lh
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.
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
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.
Ah it seems that it adds trailing zeros on to the floating point numbers and then counts all those zeros, oops!
lh
That makes sense. Glad it's demystified!