Skip to content

Pipeline file access within code #563

Discussion options

You must be logged in to vote

Hi @crooktec-tannercrook, if the json file is small, you could save the json file in code editor by simply creating a file. If it is a large json file, I'd recommend storing that file in a database like Postgresql or S3 and then pulling it from that storage.

Here is an example:

You should then reference that file using a relative path in your python code.

import json

# Get scripts directory
import pathlib
jsonpath = pathlib.Path(__file__).parent.resolve()
print(jsonpath)
  
# Opening JSON file
f = open(str(jsonpath)+'/myjsonfile.json')
  
# returns JSON object as 
# a dictionary
data = json.load(f)

print(data)

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@crooktec-tannercrook
Comment options

@saul-data
Comment options

Answer selected by saul-data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants