mirror of
https://github.com/oceanprotocol/docs.git
synced 2024-11-01 15:55:34 +01:00
GITBOOK-135: change request with no subject merged in GitBook
This commit is contained in:
parent
26a6afddb8
commit
d55f910f2d
@ -6,4 +6,41 @@ description: >-
|
|||||||
|
|
||||||
# Make a Boss C2D Algorithm
|
# Make a Boss C2D Algorithm
|
||||||
|
|
||||||
The beginning of any great algorithm for Compute-to-Data first starts by references the dataset file correctly on the Docker container. Here is the code in Javascript and in Python for how to correctly reference the dataset file that's local on the Docker container that you choose. [(If all of this is unintelligible to you, then skim the Sell NFT Outputs page!)](./) 
|
The beginning of any great algorithm for Compute-to-Data first starts by referencing the dataset file correctly on the Docker image. Here is the code in Javascript and in Python for how to correctly reference the dataset file that's local on the Docker container that you choose:
|
||||||
|
|
||||||
|
### Python
|
||||||
|
|
||||||
|
```
|
||||||
|
import csv
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
|
def get_input(local=False):
|
||||||
|
|
||||||
|
dids = os.getenv("DIDS", None)
|
||||||
|
|
||||||
|
if not dids:
|
||||||
|
print("No DIDs found in the environment. Aborting.")
|
||||||
|
return
|
||||||
|
|
||||||
|
dids = json.loads(dids)
|
||||||
|
|
||||||
|
for did in dids:
|
||||||
|
filename = f"data/inputs/{did}/0" # 0 for metadata service
|
||||||
|
print(f"Reading asset file {filename}.")
|
||||||
|
return filename
|
||||||
|
|
||||||
|
# Get the input filename using the get_input function
|
||||||
|
input_filename = get_input()
|
||||||
|
|
||||||
|
if not input_filename:
|
||||||
|
# No input filename returned
|
||||||
|
exit()
|
||||||
|
|
||||||
|
# Call the Function
|
||||||
|
with open(input_filename, 'r') as file:
|
||||||
|
# Read the CSV file
|
||||||
|
csv_reader = csv.DictReader(file)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Javascript
|
||||||
|
Loading…
Reference in New Issue
Block a user