Skip to content

Commit 836ef92

Browse files
committed
Rename :quote_char option to :quote_delimiter for CSV functions
1 parent 0a7748a commit 836ef92

File tree

8 files changed

+30
-30
lines changed

8 files changed

+30
-30
lines changed

lib/explorer/backend/data_frame.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ defmodule Explorer.Backend.DataFrame do
6161
infer_schema_length :: option(integer()),
6262
parse_dates :: boolean(),
6363
eol_delimiter :: option(String.t()),
64-
quote_char :: option(String.t())
64+
quote_delimiter :: option(String.t())
6565
) :: io_result(df)
6666
@callback to_csv(
6767
df,
@@ -93,7 +93,7 @@ defmodule Explorer.Backend.DataFrame do
9393
infer_schema_length :: option(integer()),
9494
parse_dates :: boolean(),
9595
eol_delimiter :: option(String.t()),
96-
quote_char :: option(String.t())
96+
quote_delimiter :: option(String.t())
9797
) :: io_result(df)
9898

9999
# IO: Parquet

lib/explorer/data_frame.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ defmodule Explorer.DataFrame do
601601
* `:encoding` - Encoding to use when reading the file. For now, the only possible values are `utf8` and `utf8-lossy`.
602602
The utf8-lossy option means that invalid utf8 values are replaced with � characters. (default: `"utf8"`)
603603
604-
* `:quote_char` - A single character used for csv quoting. Set to `nil` to turn off special handling and escaping
604+
* `:quote_delimiter` - A single character used for csv quoting. Set to `nil` to turn off special handling and escaping
605605
of quotes. (default: `"\""`)
606606
607607
"""
@@ -626,7 +626,7 @@ defmodule Explorer.DataFrame do
626626
infer_schema_length: @default_infer_schema_length,
627627
parse_dates: false,
628628
eol_delimiter: nil,
629-
quote_char: "\""
629+
quote_delimiter: "\""
630630
)
631631

632632
backend = backend_from_options!(backend_opts)
@@ -646,7 +646,7 @@ defmodule Explorer.DataFrame do
646646
opts[:infer_schema_length],
647647
opts[:parse_dates],
648648
opts[:eol_delimiter],
649-
opts[:quote_char]
649+
opts[:quote_delimiter]
650650
]
651651

652652
Shared.apply_init(backend, :from_csv, args, backend_opts)
@@ -809,7 +809,7 @@ defmodule Explorer.DataFrame do
809809
infer_schema_length: @default_infer_schema_length,
810810
parse_dates: false,
811811
eol_delimiter: nil,
812-
quote_char: "\""
812+
quote_delimiter: "\""
813813
)
814814

815815
backend = backend_from_options!(backend_opts)
@@ -828,7 +828,7 @@ defmodule Explorer.DataFrame do
828828
opts[:infer_schema_length],
829829
opts[:parse_dates],
830830
opts[:eol_delimiter],
831-
opts[:quote_char]
831+
opts[:quote_delimiter]
832832
]
833833

834834
Shared.apply_init(backend, :load_csv, args, backend_opts)

lib/explorer/polars_backend/data_frame.ex

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ defmodule Explorer.PolarsBackend.DataFrame do
5050
infer_schema_length,
5151
parse_dates,
5252
eol_delimiter,
53-
quote_char
53+
quote_delimiter
5454
)
5555
when module in [S3.Entry, HTTP.Entry] do
5656
path = Shared.build_path_for_entry(entry)
@@ -73,7 +73,7 @@ defmodule Explorer.PolarsBackend.DataFrame do
7373
infer_schema_length,
7474
parse_dates,
7575
eol_delimiter,
76-
quote_char
76+
quote_delimiter
7777
)
7878

7979
File.rm(path)
@@ -96,7 +96,7 @@ defmodule Explorer.PolarsBackend.DataFrame do
9696
infer_schema_length,
9797
parse_dates,
9898
eol_delimiter,
99-
quote_char
99+
quote_delimiter
100100
) do
101101
infer_schema_length =
102102
if infer_schema_length == nil,
@@ -122,7 +122,7 @@ defmodule Explorer.PolarsBackend.DataFrame do
122122
nil_values,
123123
parse_dates,
124124
char_byte(eol_delimiter),
125-
char_byte(quote_char)
125+
char_byte(quote_delimiter)
126126
)
127127

128128
case df do
@@ -205,7 +205,7 @@ defmodule Explorer.PolarsBackend.DataFrame do
205205
infer_schema_length,
206206
parse_dates,
207207
eol_delimiter,
208-
quote_char
208+
quote_delimiter
209209
) do
210210
infer_schema_length =
211211
if infer_schema_length == nil,
@@ -231,7 +231,7 @@ defmodule Explorer.PolarsBackend.DataFrame do
231231
nil_values,
232232
parse_dates,
233233
char_byte(eol_delimiter),
234-
char_byte(quote_char)
234+
char_byte(quote_delimiter)
235235
)
236236

237237
case df do

lib/explorer/polars_backend/lazy_frame.ex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ defmodule Explorer.PolarsBackend.LazyFrame do
158158
infer_schema_length,
159159
parse_dates,
160160
eol_delimiter,
161-
quote_char
161+
quote_delimiter
162162
)
163163
when is_nil(columns) do
164164
infer_schema_length =
@@ -181,7 +181,7 @@ defmodule Explorer.PolarsBackend.LazyFrame do
181181
nil_values,
182182
parse_dates,
183183
char_byte(eol_delimiter),
184-
char_byte(quote_char)
184+
char_byte(quote_delimiter)
185185
)
186186

187187
case result do
@@ -316,7 +316,7 @@ defmodule Explorer.PolarsBackend.LazyFrame do
316316
infer_schema_length,
317317
parse_dates,
318318
eol_delimiter,
319-
quote_char
319+
quote_delimiter
320320
) do
321321
with {:ok, df} <-
322322
Eager.load_csv(
@@ -333,7 +333,7 @@ defmodule Explorer.PolarsBackend.LazyFrame do
333333
infer_schema_length,
334334
parse_dates,
335335
eol_delimiter,
336-
quote_char
336+
quote_delimiter
337337
) do
338338
{:ok, Eager.lazy(df)}
339339
end

lib/explorer/polars_backend/native.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ defmodule Explorer.PolarsBackend.Native do
110110
_nil_vals,
111111
_parse_dates,
112112
_eol_delimiter,
113-
_quote_char
113+
_quote_delimiter
114114
),
115115
do: err()
116116

@@ -147,7 +147,7 @@ defmodule Explorer.PolarsBackend.Native do
147147
_nil_vals,
148148
_parse_dates,
149149
_eol_delimiter,
150-
_quote_char
150+
_quote_delimiter
151151
),
152152
do: err()
153153

@@ -258,7 +258,7 @@ defmodule Explorer.PolarsBackend.Native do
258258
_nil_vals,
259259
_parse_dates,
260260
_eol_delimiter,
261-
_quote_char
261+
_quote_delimiter
262262
),
263263
do: err()
264264

native/explorer/src/dataframe/io.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub fn df_from_csv(
4747
null_vals: Vec<String>,
4848
parse_dates: bool,
4949
eol_delimiter: Option<u8>,
50-
quote_char: Option<u8>,
50+
quote_delimiter: Option<u8>,
5151
) -> Result<ExDataFrame, ExplorerError> {
5252
let encoding = match encoding {
5353
"utf8-lossy" => CsvEncoding::LossyUtf8,
@@ -72,7 +72,7 @@ pub fn df_from_csv(
7272
.with_parse_options(
7373
CsvParseOptions::default()
7474
.with_encoding(encoding)
75-
.with_quote_char(quote_char)
75+
.with_quote_char(quote_delimiter)
7676
.with_truncate_ragged_lines(true)
7777
.with_try_parse_dates(parse_dates)
7878
.with_separator(delimiter_as_byte)
@@ -182,7 +182,7 @@ pub fn df_load_csv(
182182
null_vals: Vec<String>,
183183
parse_dates: bool,
184184
eol_delimiter: Option<u8>,
185-
quote_char: Option<u8>,
185+
quote_delimiter: Option<u8>,
186186
) -> Result<ExDataFrame, ExplorerError> {
187187
let encoding = match encoding {
188188
"utf8-lossy" => CsvEncoding::LossyUtf8,
@@ -214,7 +214,7 @@ pub fn df_load_csv(
214214
null_vals.iter().map(|x| x.into()).collect(),
215215
)))
216216
.with_try_parse_dates(parse_dates)
217-
.with_quote_char(quote_char)
217+
.with_quote_char(quote_delimiter)
218218
.with_eol_char(eol_delimiter.unwrap_or(b'\n')),
219219
)
220220
.into_reader_with_file_handle(cursor)

native/explorer/src/lazyframe/io.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ pub fn lf_from_csv(
262262
null_vals: Vec<String>,
263263
parse_dates: bool,
264264
eol_delimiter: Option<u8>,
265-
quote_char: Option<u8>,
265+
quote_delimiter: Option<u8>,
266266
) -> Result<ExLazyFrame, ExplorerError> {
267267
let encoding = match encoding {
268268
"utf8-lossy" => CsvEncoding::LossyUtf8,
@@ -284,7 +284,7 @@ pub fn lf_from_csv(
284284
null_vals.iter().map(|x| x.into()).collect(),
285285
)))
286286
.with_eol_char(eol_delimiter.unwrap_or(b'\n'))
287-
.with_quote_char(quote_char)
287+
.with_quote_char(quote_delimiter)
288288
.finish()?;
289289

290290
Ok(ExLazyFrame::new(df))

test/explorer/data_frame/csv_test.exs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,15 +224,15 @@ defmodule Explorer.DataFrame.CSVTest do
224224
}
225225
end
226226

227-
test "load_csv/2 quote_char - different quote char" do
227+
test "load_csv/2 quote_delimiter - different quote char" do
228228
data = """
229229
city,lat,lng
230230
'Elgin, Scotland, the UK',57.653484,-3.335724
231231
'Stoke-on-Trent, Staffordshire, the UK',53.002666,-2.179404
232232
'Solihull, Birmingham, UK',52.412811,-1.778197
233233
"""
234234

235-
frame = DF.load_csv!(data, quote_char: "'")
235+
frame = DF.load_csv!(data, quote_delimiter: "'")
236236

237237
assert DF.n_rows(frame) == 3
238238
assert DF.n_columns(frame) == 3
@@ -241,15 +241,15 @@ defmodule Explorer.DataFrame.CSVTest do
241241
assert frame["city"][2] == "Solihull, Birmingham, UK"
242242
end
243243

244-
test "load_csv/2 quote_char - no quote char" do
244+
test "load_csv/2 quote_delimiter - no quote char" do
245245
data = """
246246
city;nickname;lat;lng
247247
Elgin, Scotland, the UK;"Little Ireland";57.653484;-3.335724
248248
Stoke-on-Trent, Staffordshire, the UK;nil;53.002666;-2.179404
249249
Solihull, Birmingham, UK;nil;52.412811;-1.778197
250250
"""
251251

252-
frame = DF.load_csv!(data, quote_char: nil, delimiter: ";", nil_values: ["nil"])
252+
frame = DF.load_csv!(data, quote_delimiter: nil, delimiter: ";", nil_values: ["nil"])
253253

254254
assert DF.n_rows(frame) == 3
255255
assert DF.n_columns(frame) == 4

0 commit comments

Comments
 (0)