i have a *csv file in GitHub and there is also a mp3 file for each item. The link to the file consists of the data (confidence, Date, Bird and Time ) of the entry. In an table i can select inidivdual items.
Is it possible to read the selected item out and generate the link (currently hardcoded) to the recorded mp3 file?
The whole Notebook is Fetch Data from Gist / Raw GitHub URL / gitalm / Observable
You can access the data of the currently selected row via
voegel
or for example
voegel.Com_Name
However, I donât see any index that links your CSV data to the respective MP3 files. And since the filenames seem to include a rather arbitrary number right after the common name, I donât see a way to âguessâ the file name that corresponds to each entry.
Assuming that you do not have an index, Iâd recommend the following:
Generate a list of all mp3 files (file path and name)
From each file, extract the date
Index all filenames by date
Index your CSV data by date, using the same format as the files
This should give you an index that lets you match up DB entries and MP3 files.
Only a subset of your DB seems to have a matching mp3 file, then? If thatâs the case, I really recommend using a static index of your mp3 files for reference. That way you can also filter out entries without mp3 files.
Iâd also suggest to move your path building into a function, along with a few simplifications:
mp3Path = d => `https://raw.githubusercontent.com/gitalm/BirdNetPiGitHub/master/By_Common_Name/${d.Com_Name}/` +
encodeURI(`${d.Com_Name}-${Math.floor(d.Confidence*100)}%-${d.Date.replaceAll('/', '-')}-birdnet-${d.Time}.mp3`)
Dear mootari,
thanks for the help. I had problems to synchronice data from the analysis PC (BirdNETPi) to GitHub, therefore some data has no mp3. But now this is solved and just some old data remains.
To be honest, iâm not capable to make a static index for a better solution.
The idea with the functions is working great and is really simpler.
Youâll notice that you have 230 entries in your DB, but only 152 files.
I also recommend that you add the file path to your dataset instead of building it on the fly. You could even add a column âfile_existsâ to allow filtering/sorting.