@King
I found that you can use the following code to delete a file in Codebook.
from pathlib import Path file_path = Path("new_file.txt") # Deletes the file; missing_ok=True prevents errors if the file doesn't exist file_path.unlink(missing_ok=True)
For example, the following code can be used to delete all .txt files in the current directory.
from pathlib import Path current_dir = Path.cwd() files = [f.name for f in current_dir.iterdir() if f.is_file()] for file in files: if file.endswith('.txt'): file_path = Path(file) file_path.unlink(missing_ok=True)
Hello @King
The client can select multiple files on the Codebook left sidebar —> right click —> and choose Delete option.
Then select Delete on a confirmation prompt.
Hello, Wasin.w V3, thank you for responding to my query. Is there any other way? Like a code in the codebook itself to delete the files? Another question, is there a way to reset the codebook app? To somehow start fresh and delete
Hello, @wasin.w V3 thank you for responding to my query. Is there any other way? Like a code in the codebook itself to delete the files?
Another question, is there a way to reset the codebook app? To somehow start fresh and delete
I have tested the Python code to delete file. The python code needs to import the OS module to operate with the file (delete, create folder, etc.). However, the Codebook is a cloud-hosted JupyterLab server with LSEG controle and restrict environment, and the policy does not allow to import the OS module.
It means the client have to select multiple files and right click then choose the delete option manually.
About reset the codebook app, I do not know this information. Please contact the Workspace Support Team directly.
Thank you very much @wasin.w V3 Have a great rest of your day!