Read Json file
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2023 01:30 AM
I want to read json file. Code is shown as below
# credential_path ="/dbfs/Workspace/Users/dhruval/Return-label/GCP_Credential.json"
credential_path = "/Workspace/Users/dhruval/Return-label/GCP_Credential.json"
credential = spark.read.format("json").load(credential_path)
Here, credential_path is copied by right clicking on the file. I have also tried with using "dbfs" as prefix. Thought it shows there is no such file.
How to read that file
How to read that file
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2023 03:30 PM
Hi Dhruval,
Did you try using the file: prefix to the path?
credential = spark.read.format("json").option("multiline","true").load("file:/Workspace/Users/dhruval/Return-label/GCP_Credential.json")
Note: Tested on 13.3 LTS cluster