All,
I have a Survey 123 Connect form that will allow ecologists to fill out ecological (dominant trees, shrubs, forbs, etc) and abiotic (slope, aspect, drainage, etc) parameters while documenting a location. There are numerous paper/PDF forms to choose from, but my organization chose a modified version of the Virginia Natural Heritage form. It's pretty good.
What I'd like to do is build the framework to predict the ecosystem based on the answers to the various questions. Assuming that I get expert ecologists from the organization to build the key (obviously, no small feat!), I'd like to load the key data into a CSV file, place the key CSV file in the survey's media folder, read the *entire contents* of the key CSV from a JavaScript function in the survey, and then predict the ecosystem based on the survey inputs.
There's a lot of work to do here that is outside the scope of this question, but I wanted to provide context for my actual short-term issue, which is: how do I get a JavaScript function to read the full contents of a CSV?
Here's my code fragment:
try {
// Read the CSV content as a single string using pulldata
var csvContent = pulldata("@file", "Ecosystem_key.csv");
// Check if content is undefined or empty
if (!csvContent) {
return "Error: CSV content is empty or not found.";
}
...
The code is getting the error "Error: CSV content is empty or not found". At this point, the script can't distinguish between the file being empty (it's not) and not being found (likely, but unsure why). I'm at the ChatGPT level of (lack of) confidence in JS coding, but it says that I don't need to specify the relative path to the media folder.
From what I can tell based on a short search, I don't know if I can browse the media directory or not from JavaScript Survey 123. I'm not familiar with JavaScript and not familiar with JS's implementation in Survey 123, so it's unclear what the limitations are.
Any ideas would be appreciated,
Chip