learner
learner

Reputation: 1023

List the contents of a file in DBFS filestore

How can I list the contents of a CSV file (under Filestore) in Azure Databricks notebook using the %fs commands ? At least the first few lines like the "head" command in linux.

Upvotes: 0

Views: 12954

Answers (2)

dataninsight
dataninsight

Reputation: 1343

List the contents of a file in DBFS filestore

  1. Using Magic Command %fs

    %fs head /Filestore/filename.csv

  2. Using DButils directory

    dbutils.fs.head("/Filestore/filename.csv")

  3. Using DButils directory and display data in more readble format

    contents = dbutils.fs.head("/Filestore/filename.csv") display(contents)

Upvotes: 0

CHEEKATLAPRADEEP
CHEEKATLAPRADEEP

Reputation: 12788

To list the contents of a file in DBFS filestore, you can use "dbutils.fs.head" command.

Example: dbutils.fs.head("/foobar/baz.txt")

dbutils.fs.head("dbfs:/FileStore/tables/Batsmen.csv")

enter image description here

Upvotes: 4

Related Questions