1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/// CSV (Comma-Separated Values) file format support.
///
/// Read and write CSV files:
/// - Header row handling (`has_header` flag); headerless files get
/// synthetic `column_0`, `column_1`, ... names, and the first data row is
/// preserved (not consumed while inferring the column count).
/// - `read_csv` always returns `String` columns, matching
/// `DataFrame::from_csv`'s documented contract. For per-column
/// numeric/boolean type inference (`Int64`, `Float64`, `Bool`, falling
/// back to `String`), use `csv::read_csv_typed` instead.
/// - Missing values are preserved rather than replaced with a fabricated
/// placeholder: an empty string for `String` columns, or `NaN` for an
/// inferred `Float64` column that has some missing cells (`read_csv_typed`
/// never infers `Int64`/`Bool` for a column with missing cells, since
/// neither type has a way to represent "missing").
/// - A UTF-8 byte-order mark at the start of the file is stripped
/// automatically.
/// - A data row whose field count doesn't match the header is a
/// descriptive error, not silently-truncated or zero-padded data.
/// - Custom delimiters are not currently supported; the comma is fixed.
///
/// # Examples
///
/// ```rust,no_run
/// use pandrs::io;
///
/// // Read CSV with headers
/// let df = io::read_csv("data.csv", true).expect("Failed to read CSV");
///
/// // Write CSV
/// io::write_csv(&df, "output.csv").expect("Failed to write CSV");
/// ```
///
/// # Performance Tips
///
/// - For large files, consider using chunked reading
/// - Specify column types explicitly when known
/// - Use appropriate buffer sizes for better I/O performance
/// Excel file format support (requires `excel` feature).
///
/// Reads and writes the modern `.xlsx` (OOXML) format through a Pure Rust
/// implementation:
/// - Multiple sheet support
/// - Cell values and basic types
///
/// The legacy binary `.xls` format is not supported. Formulas, cell
/// formatting, and named ranges are not preserved on read or write.
///
/// # Examples
///
/// ```rust,no_run
/// # #[cfg(feature = "excel")]
/// # {
/// use pandrs::io;
///
/// // Read specific sheet
/// let df = io::read_excel("workbook.xlsx", Some("Sheet1"), true, 0, None)
/// .expect("Failed to read Excel");
///
/// // Write to Excel (requires OptimizedDataFrame)
/// // let odf = pandrs::OptimizedDataFrame::from_dataframe(&df).expect("convert");
/// // io::write_excel(&odf, "output.xlsx", Some("Data"), false)
/// // .expect("Failed to write Excel");
/// # }
/// ```
// Pure Rust xlsx (OOXML SpreadsheetML) implementation powering `excel`.
pub
/// Format trait definitions for extensible I/O.
///
/// Defines traits and types for implementing custom file format handlers.
/// JSON (JavaScript Object Notation) file format support.
///
/// Read and write JSON files with:
/// - Records orientation (`[{"col": value, ...}, ...]`)
/// - Columns orientation (`{"col": [value, ...], ...}`)
/// - Pretty printing
///
/// `write_json` serialises each column using its real DataFrame element
/// type: `i64`/`f64` columns become JSON numbers (a non-finite float
/// becomes JSON `null`, matching pandas' own `to_json` convention), `bool`
/// columns become JSON booleans, and everything else becomes JSON strings.
/// `read_json`, conversely, always returns `String` columns -- every JSON
/// value (numbers and booleans included) is converted to its text form,
/// and `null` or a missing key becomes an empty string -- there is
/// currently no read-side type inference for JSON, unlike
/// `csv::read_csv_typed` for CSV.
///
/// # Examples
///
/// ```rust,no_run
/// use pandrs::io;
/// use pandrs::io::json::JsonOrient;
///
/// // Read JSON
/// let df = io::read_json("data.json").expect("Failed to read JSON");
///
/// // Write JSON
/// io::write_json(&df, "output.json", JsonOrient::Records).expect("Failed to write JSON");
/// ```
/// Parquet columnar file format support (requires `parquet` feature).
///
/// Read and write Apache Parquet files for efficient columnar storage:
/// - Columnar compression
/// - Predicate pushdown
/// - Schema evolution
/// - Row group statistics
///
/// # Examples
///
/// ```rust,no_run
/// # #[cfg(feature = "parquet")]
/// # {
/// use pandrs::io;
///
/// // Read Parquet file
/// let df = io::read_parquet("data.parquet")
/// .expect("Failed to read Parquet");
///
/// // Write with compression (requires OptimizedDataFrame)
/// // let odf = pandrs::OptimizedDataFrame::from_dataframe(&df).expect("convert");
/// // io::write_parquet(&odf, "output.parquet", None)
/// // .expect("Failed to write Parquet");
/// # }
/// ```
///
/// # Performance Tips
///
/// - Parquet is optimized for columnar operations
/// - Use predicate filters to read only needed data
/// - Choose appropriate compression (snappy, gzip, lz4)
/// Streaming I/O for processing data in chunks.
///
/// Process large datasets that don't fit in memory:
/// - Chunked reading and writing
/// - Pipeline processing
/// - Backpressure handling
// Re-export commonly used functions
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;