This manual will explain step by step how to use the API of eLabFTW to automatically upload entries to the resources in a specific team using the eLab_loader: https://github.com/KJPMolgenLab/ELAB\_LOADER You can use the script and execute it via the terminal of your device or with a source code editor. The first step explains how to install the source code editor Visual Studio Code (VS Code). If this is not relevant to you, you can continue directly with Step 3
Installing VS Code, Git and Python on your PC:
- Download VS Code: https://code.visualstudio.com/download
- Start installation and select default settings *
- Install Git on the PC https://git-scm.com/downloads *
- Install Python on the PC https://www.python.org/downloads/windows/
- Important installation setting: Click on 'Add python to Path'
* - Start VS Code ## 2\. Setting up VS Code
- First you have to chose a theme
- Click "<- Welcome" at the top left to get to the main page
- There you click on 'Open Folder'
- Now select a folder in which you want to save everything
- Create a folder and name it as it makes sense to you
- The folder now appears on the left in VS Code
In VS Code the Terminal is accessible via the menu bar, click on "new terminal"
- Move to the folder you want to work with. Therefore you can use the command cd and the name of the folder to get there.
- In the correct folder, type in the following command to clone the eLab_Loader project
- After a few seconds (depending on how fast your computer is) a new folder (in your folder) with the name "ELAB_LOADER" will be created
- Use the command cd to get into this new folder
- In the next step, the required packages will be installed, therefore type in the following command
- pip install -r requirements.txt
Everything you need should be installed now. We will continue to run the script.
We are still in the terminal in the "ELAB_LOADER" folder
- Type in the following command to run the script
- ./elabloader.py
- If nothing happens and the next command line will appear, then the script is started. Otherwise, an error message will be displayed
- Next we need to type in a long command to use the script, beforehand a few things need to be prepared
- Prepare the excel list with your chemicals (consumables)
- Therefore open the "example" folder and the edit the "example_cons" file
- Take care that the red marked columns are mandatory, but you are allowed to have as many white columns you need next to the excisting ones
- Then you need an API key in the team in eLabFTW where you work, so please generate it with read and write permissions
- You also need the ID of the category in eLabFTW to which you want to upload this Excel list.
- The command to run the script for consumable might look like this: ./elabloader.py --apikey "enter your key" --url "https://yourelab.yourelabsending.lab/api/v2/" --file ./Example/Example_cons.xlsx --cat_id "numberofyourcatid"
With this you will be able to populate the resources in eLabFTW. However it is recommended to first try this out with a few test entries.
There a several ways to find out which ID you category in eLabFTW has.
- You have access to the admin panel in eLabFTW
- Call up the categories in the admin panel and click on "edit" of the category where you want to get the ID.
- Now check out the URL, the last number is the ID of the category
- You don't have access to the admin panel
- Go to resources in eLabFTW and create a new empty entry in the category.
- Back to the resources,the new entry is displayed and now you click on the category name above the title of the entry
- In the URL (the first number) is your category ID, it is indicated by "cat=..."
- Use F12 in your Browser and open the developer tools interface
- Go to resources in eLabFTW and create a new empty entry in the category.
- Back to the resources,the new entry is displayed and now you click on the "F12" button of your keyboard
- The developer tools of your browser appears, use the picker and click on the name of the category (above the title of the entry)
- A line of code will be highlighted and there it's written "data-value=..."