Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Do not crash when there's invalid tabular data #106

Merged
1 commit merged into from
Sep 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/kino_explorer/data_transform_cell.ex
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ defmodule KinoExplorer.DataTransformCell do
case df do
nil -> nil
%DataFrame{} -> DataFrame.dtypes(df) |> normalize_dtypes()
_ -> df |> DataFrame.new() |> DataFrame.dtypes() |> normalize_dtypes()
_ -> maybe_data_options(df)
end

[Map.put(operation, "data_options", data_options)]
Expand Down Expand Up @@ -945,4 +945,13 @@ defmodule KinoExplorer.DataTransformCell do
end)
|> Enum.into(%{})
end

defp maybe_data_options(df) do
try do
df |> DataFrame.new() |> DataFrame.dtypes() |> normalize_dtypes()
rescue
_ ->
nil
end
end
end