Reputation: 1023
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
Reputation: 1343
List the contents of a file in DBFS filestore
Using Magic Command %fs
%fs head /Filestore/filename.csv
Using DButils directory
dbutils.fs.head("/Filestore/filename.csv")
Using DButils directory and display data in more readble format
contents = dbutils.fs.head("/Filestore/filename.csv")
display(contents)
Upvotes: 0
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")
Upvotes: 4