Hey all, I am attempting to create a report template for a biological firm, and I need to conditionally print some sections of the report and then conditionally populate said sections with particular answer values based on the first two characters in the answer. This is the only way data was collected, and I am hoping to be able to parse each answer string and print it under a heading related to that answer's taxonomical classification based on the presence of a substring. I'll give a specific example below. At this point, I'd even be willing to brute force this by listing a conditional for each answer...would rather not get to that point.
The gist of it:
So, the data is basically a massive list of non-target species observations that the biologists observed while in the field. The data is as follows, with an example from each classification:
(AAFCF+) Xenopus laevis, (AAFCF+) African clawed frog
(BCAGU ) Larus californicus, (BCAGU ) California gull
(IBOVA ) Bombus vandykei, (IBOVA ) Van Dyke bumble bee
(MBOBC ) Lynx rufus, (MBOBC ) Bobcat
(RDEIG ) Dipsosaurus dorsalis, (RDEIG ) Desert iguana
Where: the first letter of the animal's alpha code (in the parentheses) is the classification of the animal, which is corresponds to amphibian, bird, insect, mammal, and reptile, respectively. This is all the data we have for each entry, which brings me to my main issue...
What I need to do is take each of these data points and place them in a table. That's easy enough of course, but what is ACTUALLY needed is a table that has the sightings broken down into their respective type classification. Under each type classification heading, I need to print only those animals within that classification. I also need the headings for each section (amphibian, bird, etc.) to only print when there was a sighting of a species within that classification. And finally, I'd love to print the both the scientific and common name of each species as I've described above, only I'd like to remove the parentheses and the contained alpha code. Here's an example of the final output, along with some template code that I've placed in there for my own benefit during this process. (NOTE: I know that the template will need many, more loops than the one I've got here, this is not my working draft.)
|
${#wildlife_observations}${wildlife_other}
|
|
Scientific Name
|
Common Name
|
|
Reptiles
|
|
${wildlife_observed | getValue:""}
|
${wildlife_observed}
|
|
Amphibians
|
|
Anaxyrus boreas
|
Western toad
|
|
Birds
|
|
Aquila chrysaetos*
|
Golden eagle
|
|
Insects
|
|
Zenaida macroura
|
Mourning dove
|
|
Mammals
|
|
Sylvilagus audubonii
|
Desert cottontail
|
|
${/}
|
*Denotes special-status species
So, there you have it. Can anyone think of a solution to this? Is there a way to grab individual characters in a string on the fly in a template? Or to check a string for the presence of a substring? Will I be able to conditionally print headings but then loop over the records and populate the sections?
Final note...I figured I should outline my current plan, which is as follows: conditionally print the headings based on the presence of a species in said classification, triggered by the first record that the report generator comes across. I will of course figure out if the record exists by searching each data point in this question for "(A", "(B", "I", "(M", and "(R". Then, I will either loop through ALL of the answers again, only printing the ones that contain the "(X" for said section, or I will just print until I come across the next "(X" in the progression. Thankfully, the domain list is grouped alphabetically so either should work. I think that this logic will work just fine, I just need some help with the syntax to get me there.
Thank you all for your help!!