Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
thbar committed Feb 7, 2025
1 parent 8d1a169 commit 77641bd
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions apps/transport/lib/irve/data_frame.ex
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ defmodule Transport.IRVE.DataFrame do
>
Congratulations for reading this far.
Let's continue with alternate columns separators.
iex> Transport.IRVE.DataFrame.dataframe_from_csv_body!("foo;bar\\n123;14.0")
#Explorer.DataFrame<
Polars[1 x 2]
foo s64 [123]
bar f64 [14.0]
>
"""
def dataframe_from_csv_body!(body, schema \\ Transport.IRVE.StaticIRVESchema.schema_content(), strict \\ true) do
dtypes =
Expand All @@ -115,6 +124,14 @@ defmodule Transport.IRVE.DataFrame do
}
end)

body
|> String.split("\n", parts: 2)
|> Enum.at(0)
|> String.replace(~r/\w/, "")
|> String.graphemes()
|> Enum.frequencies()
|> IO.inspect(IEx.inspect_opts)

# to be tested - do not call `load_csv!` as it will `inspect` the error
case Explorer.DataFrame.load_csv(body, dtypes: dtypes) do
{:ok, df} -> df
Expand Down

0 comments on commit 77641bd

Please sign in to comment.