Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding functional For loop Try/Catch example code
Hi Marcela, this is a working example of complex indexing that happens in the for loop and try blocks of the R SDG formatting code. I left in lines that helped me put the indexing together in pieces, and hopefully can help you understand the pieces of the long indexing call. These lines have "#FOR DEMO" written above them. It turns out the .item() calls at the end of some of the expressions are critical to prevent the mis-matched indexing errors we were getting earlier (they access the actual elements in the data structures returned by the expressions). The 'try' blocks are also essential I realized, because the lookup fails if a field collected sample has not yet been processed by the lab. To incorporate this into the Python function, remove the #FOR DEMO lines, and add another indexing/assignment line with the correct column names substituted in the try block (so there should be a total of 2 assignment lines within each try block). Then make the 3 different try blocks like in the R code. Let me know if you have any questions!
- Loading branch information