K_Anudeep
Databricks Employee
Databricks Employee

Hello @ToBeDataDriven ,

If it's a notebook cell, you can silence the output of the cell by using %%capture 

%%capture
dbutils.fs.put("dbfs:/FileStore/anudeep/datasets/word_count/tmp/3.txt","foo")

 

If you want to do it in your code, then there is no flag to silence the output, but you can use a wrapper function in Python as a workaround.

Code:

import os
from contextlib import redirect_stdout, redirect_stderr
from io import StringIO

def dbutils_put(path: str, contents: str, overwrite: bool = True) -> None:
    sink = StringIO()
    with redirect_stdout(sink), redirect_stderr(sink):
        dbutils.fs.put(path, contents, overwrite)

dbutils_put("dbfs:/FileStore/anudeep/streaming_datasets/word_count/tmp/4.txt","abc")

 

Please let me know if this works for you. Thanks

 

Anudeep

View solution in original post