-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUntitled Notebook 2024-10-17 21_46_13.py
62 lines (39 loc) · 1.25 KB
/
Untitled Notebook 2024-10-17 21_46_13.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Databricks notebook source
# MAGIC %md
# MAGIC # we have 4 types of utilities:
# MAGIC ### File system utilities
# MAGIC ### Secrets utilities
# MAGIC ### widget utilities
# COMMAND ----------
# MAGIC %md
# MAGIC ## File System utilities
# COMMAND ----------
# MAGIC %md
# MAGIC ### On this notebook we review some scripts about file system utilities.
# MAGIC - we should remember we can use file system utilities on python , Scala and R, but not in SQL
# COMMAND ----------
# fs refers to file system utility
%fs
ls
# COMMAND ----------
# MAGIC %fs
# MAGIC ls /databricks-datasets
# COMMAND ----------
#if we want to see all utility files we can use dbutil.fs.ls command.
# here we checked utility files of root folder of databricks
dbutils.fs.ls('/')
# COMMAND ----------
# the directories above contains few datasets that we can use. for example we enter into Covid folder
dbutils.fs.ls('/databricks-datasets/COVID')
# COMMAND ----------
for files in dbutils.fs.ls('/databricks-datasets/COVID'):
print(files)
# COMMAND ----------
for files in dbutils.fs.ls('/databricks-datasets/COVID'):
if files.name.endswith('/'):
print(files.name)
# COMMAND ----------
dbutils.fs.help()
# COMMAND ----------
dbutils.fs.help('ls')
# COMMAND ----------