Step 3. Stage the data files

Execute PUT to upload (stage) sample data files from your local file system to the stages you created in Step 2. Create stage objects.

Staging the CSV sample data files

Execute the PUT command to upload the CSV files from your local file system.

  • Linux or macOS

    PUT file:///tmp/load/contacts*.csv @my_csv_stage AUTO_COMPRESS=TRUE;
    
    Copy
  • Windows

    PUT file://C:\temp\load\contacts*.csv @my_csv_stage AUTO_COMPRESS=TRUE;
    
    Copy

Let us take a closer look at the command:

  • file://<file-path>[/]contacts*.csv specifies the full directory path and names of the files on your local machine to stage. Note that file system wildcards are allowed.

  • @my_csv_stage is the stage name where to stage the data.

  • auto_compress=true; directs the command to compress the data when staging. This is also the default.

The command returns the following result, showing the staged files:

+---------------+------------------+-------------+-------------+--------------------+--------------------+----------+---------+
| source        | target           | source_size | target_size | source_compression | target_compression | status   | message |
|---------------+------------------+-------------+-------------+--------------------+--------------------+----------+---------|
| contacts1.csv | contacts1.csv.gz |         694 |         506 | NONE               | GZIP               | UPLOADED |         |
| contacts2.csv | contacts2.csv.gz |         763 |         565 | NONE               | GZIP               | UPLOADED |         |
| contacts3.csv | contacts3.csv.gz |         771 |         567 | NONE               | GZIP               | UPLOADED |         |
| contacts4.csv | contacts4.csv.gz |         750 |         561 | NONE               | GZIP               | UPLOADED |         |
| contacts5.csv | contacts5.csv.gz |         887 |         621 | NONE               | GZIP               | UPLOADED |         |
+---------------+------------------+-------------+-------------+--------------------+--------------------+----------+---------+
Copy

Staging the JSON sample data files

Execute the PUT command to upload the JSON file from your local file system to the named stage.

  • Linux or macOS

    PUT file:///tmp/load/contacts.json @my_json_stage AUTO_COMPRESS=TRUE;
    
    Copy
  • Windows

    PUT file://C:\temp\load\contacts.json @my_json_stage AUTO_COMPRESS=TRUE;
    
    Copy

The command returns the following result, showing the staged files:

+---------------+------------------+-------------+-------------+--------------------+--------------------+----------+---------+
| source        | target           | source_size | target_size | source_compression | target_compression | status   | message |
|---------------+------------------+-------------+-------------+--------------------+--------------------+----------+---------|
| contacts.json | contacts.json.gz |         965 |         446 | NONE               | GZIP               | UPLOADED |         |
+---------------+------------------+-------------+-------------+--------------------+--------------------+----------+---------+
Copy

List the staged files (optional)

You can list the staged files by using the LIST command.

CSV

LIST @my_csv_stage;
Copy

Snowflake returns a list of your staged files.

JSON

LIST @my_json_stage;
Copy

Snowflake returns a list of your staged files.

Next: Step 4. Copy data into the target tables