# Spark Lab Workflow: Upload, Transform, Write and Save a Result

> A step-by-step PySpark workflow in the Spark Lab: bring in a file, transform it, write the result to Docker, view it and keep its lineage.

Page: https://datautility.in/blog/spark-lab-upload-transform-write-save-workflow
This is the Markdown copy of the page. The tool itself runs in the browser: your files are processed on your own device and are not uploaded.

Published 2026-11-27 · Analyze & protect · pyspark workflow, spark lab tutorial, pyspark write parquet docker, pyspark export csv, spark lab recent files, pyspark data lineage

This is the full path of one job in the Spark Lab, from getting a file in to keeping the result. Each step says what the page does and where the data ends up, so you always know whether something is in Docker or in the browser.

Open the tool: [Spark Lab](https://datautility.in/sparklab)

## Before you start

Run the Set up and Start commands from the [Spark Lab](https://datautility.in/pyspark-spark-ui-lab) page, paste the token, click Connect and say Yes to the pop-up. You are then on the code page. If you have not done this yet, read [Learn PySpark and the Spark UI free](https://datautility.in/blog/learn-pyspark-and-the-spark-ui-free) first.

## Step 1: get a file into the lab

There are three ways, and all of them put the file on the Docker disk, not in the browser.

- **Upload a file**: pick a CSV, JSON or Parquet file. It goes straight into /data/uploads inside the lab. The page adds code to read it.

- **From recent files**: pick a file you converted or cleaned in another Data Utility tool, for example a CSV you turned into Parquet with the [Format Converter](https://datautility.in/format-converter). It is copied into the lab as Parquet, so the column types are kept.

- **A folder on your computer**: for files of several GB, start the lab with the folder command and copy the file into spark-lab/uploads. Click Refresh under Your files and it appears. This skips the browser completely.

## Step 2: transform it

Write normal PySpark in the editor. spark, F (functions), T (types) and DATA are ready to use, and variables are kept between runs. For example: filter rows, add a column with withColumn, group and aggregate. Run it with the Run button or Ctrl+Enter. Open the Spark UI to see the jobs and stages your code created.

## Step 3: write the result to the Docker disk

You do not need to remember the syntax. Under the editor, click **Parquet folder**, **CSV folder**, **One Parquet file** or **One CSV file**. The page inserts the write code for your last DataFrame:

- A folder: df.write.mode("overwrite").parquet("/data/outputs/name") writes a folder of part files, one per task. This is what Spark does by default and it scales to big data.

- A single file: export(df, "name", "parquet") writes one file, which is easier to open and can be saved to Recent files.

After you run it, a green box says where the data landed, for example /data/outputs/north_orders/, with commands you can copy.

## Step 4: look at the result

Click **Files in Docker** in the top bar. You will see the file or folder with its size. Click **View** to see the first rows as a table. In the Spark UI, the SQL / DataFrame tab shows the write query (InsertIntoHadoopFsRelationCommand) with the number of files and bytes written, and the Stages tab has an Output column. To see the files in a terminal, read [where the Spark Lab stores your data](https://datautility.in/blog/where-spark-lab-stores-your-data-docker).

## Step 5: save it to Recent files and keep its lineage

For a single file, click **Save to recent**. It joins your Recent files, which are kept in your browser (up to 100,000 rows). Its history then lists every step: the original file, any conversion, and the Spark step with the code you ran. Open the [Data Lineage](https://datautility.in/data-lineage) page to see it. Use this for small and medium results. Big results stay in Docker.

## Step 6: use it somewhere else

A saved result is a normal Recent file. Open it in the Format Converter, the Data Profiler or any other tool. Or copy the original file out of Docker with docker cp and use it in your own code.

## Which option for which size

- Up to about 100,000 rows: export() and Save to recent, so you get lineage and can reuse the file in other tools.

- Up to a few GB: upload through the page, write a folder, view the first part, copy it out with docker cp.

- Several GB and more: use the folder option, write folders, and read results from spark-lab/outputs on your own disk.

## Common questions

- Why can I not Save a folder to Recent files? A Spark folder holds many part files and can be huge. Write one file with export() if you want it in Recent files.

- Where is my upload? In /data/uploads inside the lab, not in the browser.

- I restarted the lab and my files are gone. The Start command must include the data volume, which keeps /data. Copy the current Start command from the Spark Lab page.

## How to use the Spark Lab: step by step

1. Get a file in: upload, recent file or folder
2. Transform it with PySpark and Run
3. Insert the write code and run it
4. View it under Files in Docker, then save a single file to Recent files

## When to use the Spark Lab

- Following one PySpark job from file to saved result
- Choosing between a folder and a single output file
- Keeping lineage for a Spark result
- Working out where a file is stored

## Frequently asked questions

### Does an uploaded file stay in the browser?
No. It goes straight into the lab on your computer, into /data/uploads. The page keeps nothing.

### What is the difference between export() and df.write?
export() writes one file you can view and save to Recent files. df.write writes a folder of part files, which is how Spark scales to big data.

Tip: Test your transformation on a small sample first with limit(), write the result once, and check it with View before you run the job on the full data.

## Also try

- [Where the Spark Lab stores your data](https://datautility.in/blog/where-spark-lab-stores-your-data-docker)
- [Process 10 GB files with PySpark on a laptop](https://datautility.in/blog/process-large-files-pyspark-docker-laptop)

## More guides

- [Data Profiler: Check Data Quality Before You Use It](https://datautility.in/blog/data-profiler-check-data-quality)
- [Compare Two CSV or Excel Files: Find Added, Removed and Changed Rows](https://datautility.in/blog/compare-two-csv-files-find-differences)
- [Data Masking: Hide Emails, Phones and Names Before Sharing](https://datautility.in/blog/data-masking-hide-emails-phones-pii)
