cancel
Showing results for 
Search instead for 
Did you mean: 
Get Started Discussions
Start your journey with Databricks by joining discussions on getting started guides, tutorials, and introductory topics. Connect with beginners and experts alike to kickstart your Databricks experience.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to download the results in batches

Lumoura
New Contributor

Hello, how are you?

I`m trying to download some of my results on databricks and the sheets is around 300mb, unfortunately my google sheets is not open files that has more then 100mb.  Is that any chance that i could download the results in batches to join after manually? (The results is more then 100k lines)



2 REPLIES 2

szymon_dybczak
Esteemed Contributor III

Hi @Lumoura ,

So maybe just save the result as a csv to Volume and then use pyspark to split this file into smaller parts, i.e using repartition:

df = df.repartition(num_partitions)


 

NandiniN
Databricks Employee
Databricks Employee

Hey, 

Thinking of more alternates to repartition:

1- Use the limit and offset options in your SQL queries to export data in manageable chunks. For example, if you have a table with 100,000 rows and you want to export 10,000 rows at a time, you can use the following queries:

SELECT * FROM your_table LIMIT 10000 OFFSET 0;
SELECT * FROM your_table LIMIT 10000 OFFSET 10000;
SELECT * FROM your_table LIMIT 10000 OFFSET 20000;
...

 (Adjust the LIMIT and OFFSET values based on the size of your data and the number of rows you want to export in each batch)

 

2-  Save the results of each query to a separate CSV file. You can use the dbutils.fs module to save the results to DBFS (Databricks File System) and then download them to your local machine.

3 - My personal fav is splitting, when working with heap dumps, you could use that too once you have the large file, split them up.

split -b 100M large.tar.gz large.tar.gz.part

 

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group