cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Read Json file

dhruval
New Contributor

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
1 REPLY 1

Krishnamatta
New Contributor III

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

 

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group