# Count string occurrences in field calculator

Question asked by breezo44 on Mar 11, 2014
Hi all,
I'll do my best to explain what I'm trying to do here.
I have an attribute table that is the result of a spatial join (join of a FishNet and aerial survey sighting data). The Species field was created with a join merge rule, so that if a species group occurred more than one time in a I could see that. The number field was created as a sum of the number of individuals sighted within a cell. For example, if one group of Er with 3 animals was sighted, then the Species column would say Er and the number field equals 3. If one Er group contained 2 animals and one Er group containing 3 animals was seen then the Species field would equal ErEr and the number field would equal 5. This gets further complicated when more than one species was sighted in a cell.  I did this because I need to quantify by the number of groups and the number of animals in each grid cell for each species.
What I am now trying to do is add fields that give me presence/absence (0/1), number of groups, and number of animals for each species in each cell BY species. My thought was to use the field calculator to count the number of string occurrences in the Species field to give me the number of groups. I did realize that the Join_Count field represents this value UNLESS more than one species is present.  If there is a better/alternative suggestion at trying to do what I am doing, then I'm all ears!
I've attached a screen shot of the attribute table. When the table is complete it should have the _Pres, _Group and _Number fields for each of three species.
[ATTACH=CONFIG]32127[/ATTACH]
Also, here are the scripts I have used, so far, to populate the Er_Pres, Er_Groups and Er_Number fields.
[ATTACH=CONFIG]32128[/ATTACH]
[ATTACH=CONFIG]32129[/ATTACH]
[ATTACH=CONFIG]32130[/ATTACH]