Before you start
Prepare file access and a client connection using Read and write files. For the read example, place this UTF-8 file in accessible storage:Read data
Use an explicit schema to keep the identifier and amount types fixed. The header must match the column names and order.(1, 12.5) and (2, 7.5). Without an explicit schema, set inferSchema 'true' to infer types from a bounded sample. With inference disabled, discovered columns use string types.
Write data
Use thespark connection from the shared file guide. Choose a private output directory covered by a writable mount.
mode("append") to add rows. Repeating an append adds another copy of those rows.
Options
For storage and folder selection options, see shared read options. Writer
mode("overwrite") is separate from the parsing option named mode.
Data types and limits
CSV stores text, so use a schema for numeric, date, or timestamp columns that need stable types. Values must parse as those types. All selected files must have a compatible schema and matching headers. Quoted fields can contain newlines. The CSV reader handles them directly; amultiLine option is not accepted for CSV. Use compression 'zstd' for Zstandard input and a matching file filter for compressed names.
Direct writes do not accept partitioning or table-style row mutations. For those operations, choose a supported table connector.