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:ย 

upload local files into DBFS

Young_TackPark
New Contributor

I am using Databricks Notebook Community Edition (2.36) and want to upload a local file into DBFS. Is there any simple Hadoop commands like "hadoop fs -put ..."? Any help would be appreciated.

2 REPLIES 2

kutt4n
New Contributor II

You could create a table from a local file ( if you have some sort of structured data ). You just have to choose File as the data source.

If you could make it available in a url that could be accessed from anywhere ( even hosting the file in a local webserver ) - you could use

%fs wget http://filename

and use

dbutils.fs.cp 

to copy from "file:/path" to "dbfs:/path"

check https://docs.databricks.com/user-guide/dbfs-databricks-file-system.html for more details

sushrutt_12
New Contributor II

Python 2.7:

import urllib.request
urllib.urlretrieve("https://github.com/sushrutt12/DataSets/blob/master/final_chris.zip","/tmp/chris_data.zip") dbutils.fs.mv("file:/tmp/chris_data.zip", "dbfs:/data/chris_data.zip")

Python 3.x:

 
  1. import urllib.request
  2. urllib.request.urlretrieve("https://github.com/sushrutt12/DataSets/blob/master/final_chris.zip","/tmp/chris_data.zip")
  3. dbutils.fs.mv("file:/tmp/chris_data.zip","dbfs:/data/chris_data.zip")

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