Counting characters


    Mar 03 2009 | 5:54 pm
    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

    • Mar 03 2009 | 6:59 pm
      Using strlen by Jasch you could do:
      Best, Joerg
    • Mar 03 2009 | 7:51 pm
      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.
    • Mar 03 2009 | 8:06 pm
      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
    • Mar 03 2009 | 8:33 pm
      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!
    • Mar 03 2009 | 8:42 pm
      How odd, I'll attach the file here as well then.
      lh
    • Mar 03 2009 | 10:39 pm
      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.
    • Mar 03 2009 | 10:44 pm
      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
    • Mar 03 2009 | 11:33 pm
      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.
    • Mar 03 2009 | 11:47 pm
      Ah it seems that it adds trailing zeros on to the floating point numbers and then counts all those zeros, oops!
      lh
    • Mar 04 2009 | 12:00 am
      That makes sense. Glad it's demystified!