From a general programming perspective I’ve got two suggestion regarding this issue.
Firstly you’re calling the split function on an async function, so I’m not sure how secure that is. I think it would be better to do the await first, and then do the split afterwards, if there is content in the file.
Secondly, does this happen with all files or just with newly created files (or even non-existing files)? You might need some checks to verify the file exist, and have contents before you try to split it into parts.
Either way I would split the line with the read, debug the output from the read so that you can see when and why the split fails.
In essence that is doing what I commented upon, namely doing the await on the read, and not the split. You just don’t store the result in an intermediate variable (nor check it for it being empty/undefined).
The script has now all basic functionalities. Works perfectly well. It creates an entry in the Day Planner note, puts it in the right place, and does some checks ( correct format, no duplicates …)
I would like to include the Obsidian ICS plugin by calling the command directly with the Obsidian API. But this plugin only works if the active note is named “YYYY-MM-DD”. I will see if i can modify the plugin or find some other approach.
I would like to grab my Google Calendar in the Day Planner. With my script i could then add events on the fly.