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

How do i stop pyspark from outputting text

halox6000
New Contributor III

I am using a tqdm progress bar to monitor the amount of data records I have collected via API. I am temporarily writing them to a file in the DBFS, then uploading to a Spark DataFrame. Each time I write to a file, I get a message like 'Wrote 8873925 bytes.' How do I stop it from outputting this?

1 REPLY 1

Kaniz_Fatma
Community Manager
Community Manager

Hi @halox6000, To stop the progress bar output from tqdm, you can use the disable argument. Set it to True to silence any tqdm output. In fact, it will not only hide the display but also skip the progress bar calculations entirely1. Hereโ€™s an example of how to use it:

from tqdm import tqdm
import time

for i in tqdm(range(10), disable=True):
    time.sleep(1)

In this example, the progress bar wonโ€™t be displayed, and the output messages will be suppressed. You can adapt this approach to your specific use case in Databricks to prevent the โ€œWrote X bytesโ€ messages from cluttering your logs. If you need to dynamically switch the behavior, consider adding a command-line argument to your scri...1.

Happy coding! ๐Ÿ˜Š

To ensure we provide you with the best support, could you please take a moment to review the response and choose the one that best answers your question? Your feedback not only helps us assist you better but also benefits other community members who may have similar questions in the future.

If you found the answer helpful, consider giving it a kudo. If the response fully addresses your question, please mark it as the accepted solution. This will help us close the thread and ensure your question is resolved.

We appreciate your participation and are here to assist you further if you need it!

 
Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!