5.2.4: How to Incorporate Data Files in Your Code Blocks- For Python
There are a number of ways data files and can be incorporated into code blocks. However, ensure that you have already followed the steps in the introduction to the CKEditor Binder Plugin Tutorial here .
Method 1: Using wget
The first method that can be used to get a data file in your code block is with wget. Follow the example below and replace the example URL with the one attained in the previous step.
Remember to press the "Run" button prior to pressing "OK". Printing both the code and output without, will the below result, to avoid this simply check "Insert Code Only" after pressing "Run".
Once the data file has been loaded, use Python code that you may normally use to read out the lines in the data file. An example code block has been provided below.
To ensure that the above code block runs successfully, the user needs to run the wget code prior to running the above code if both parts are added in separately.
Method 2: Using Python Libraries
The CKEditor Binder Plugin supports Python 3, libraries that are supported by this version of Python may be used to read in the file. An example code block is provided below.