Data import and export

This cheat sheet provides quick access to common data import and export commands. For more detailed information, see the Data guide.

Data import

CSV

import io.deephaven.csv.CsvTools

// Read a CSV file from a URL or file path
table = CsvTools.readCsv("https://path/to/your/file.csv")
// Or from a local file path
table = CsvTools.readCsv("/path/to/your/file.csv")
from deephaven.csv import read

# Read a CSV file from a URL or file path
table = read("https://path/to/your/file.csv")
# Or from a local file path
table = read("/path/to/your/file.csv")

Parquet

import io.deephaven.parquet.table.ParquetTools

// Read a Parquet file
table = ParquetTools.readTable("/path/to/your/file.parquet")
from deephaven.parquet import read

# Read a Parquet file
table = read("/path/to/your/file.parquet")

Kafka

import io.deephaven.kafka.KafkaTools

// Consume from a Kafka topic
kafkaProps = new Properties()
kafkaProps.put('bootstrap.servers', 'localhost:9092')
table = KafkaTools.consumeToTable(
    kafkaProps,
    'your_topic',
    KafkaTools.ALL_PARTITIONS,
    KafkaTools.ALL_PARTITIONS_DONT_SEEK,
    KafkaTools.Consume.IGNORE,
    KafkaTools.Consume.simpleSpec('Value', java.lang.String),
    KafkaTools.TableType.append()
)
from deephaven.stream.kafka import consumer as kc
import deephaven.dtypes as dht

# Consume from a Kafka topic
table = kc.consume(
    {"bootstrap.servers": "localhost:9092"},
    "your_topic",
    key_spec=kc.KeyValueSpec.IGNORE,
    value_spec=kc.simple_spec("Value", dht.string),
    table_type=kc.TableType.append(),
)

Data export

Parquet

import io.deephaven.parquet.table.ParquetTools

// Write a table to a Parquet file
ParquetTools.writeTable(myTable, "/path/to/your/output.parquet")
from deephaven.parquet import write

# Write a table to a Parquet file
write(my_table, "/path/to/your/output.parquet")

CSV

import io.deephaven.csv.CsvTools

// Write a table to a CSV file
CsvTools.writeCsv(myTable, "/path/to/your/output.csv")
from deephaven.csv import write

# Write a table to a CSV file
write(my_table, "/path/to/your/output.csv")

Deephaven database

// Write a table to the Deephaven database
db.addUnpartitionedTable("MyNamespace", "MyTable", myTable)
# Write a table to the Deephaven database
db.add_unpartitioned_table("MyNamespace", "MyTable", my_table)