alphydan
Hello,
I’m an elixir beginner, exploring livebook. I’m running a local notebook on a linux machine. Initially I tried to import a CSV file with Explorer like so:
alias Explorer.{DataFrame, Series}
path_to_csv = "./some_file.csv"
DataFrame.from_csv!(path_to_csv)
However, I am seeing the following error:
** (RuntimeError) from_csv failed: {:polars, "Could not parse `Fee Amount`
as dtype Int64 at column 16.\nThe current offset in the file is 249 bytes.\n\n
Consider specifying the correct dtype, increasing\n
the number of records used to infer the schema,\n
enabling the `ignore_errors` flag, or adding\n`Fee Amount` to the `null_values` list."}
(explorer 0.5.5) lib/explorer/data_frame.ex:438: Explorer.DataFrame.from_csv!/2
To check if the problem was indeed with the data in the column Fee Amount, I filled the column with integers. But I get the same error. What can I try to better diagnose this problem?
Trending in Questions
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
benwilson512
Hi @alphydan welcome! Are you able to provide a sample of that CSV file?
BradS2S
You can use :dtype to explicitly set the data type for a column instead of letting it try to infer it.
al2o3cr
One small thing that jumps out:
This sounds like it’s on at least the second line of the file, and so should be data
That’s a reference to the
with_null_valuessetting inpolars_io::csv::CsvReader, which is intended to parse values like"n/a"tonull.The message suggests that the reader found the literal string “Fee Amount” where it expected data.
alphydan
@BradS2S @benwilson512 @al2o3cr Thank you for all your suggestions. “Fee Amount” was not on the second line, but on the header (first row).
A potential problem with the header led me to try changing all headers to the format
something_or_the_otherinstead ofSomething Or \n the Other.I found that it failed when I had a return character inside the header. The CSV gets imported correctly now. Thank you for the prompt replies.
LostKobrakai
Were these quoted? If no, then that’s indeed invalid. If they were, then this sounds like a but in the csv parser.
alphydan
Ok, here’s an example to further diagnose the problem:
Running
$ cat -v example_failing.csvin the terminal shows:(Where
$corresponds to\nor Unix line endings). Trying to import it in livebook:leads to this error:
BradS2S
Remove all the new line characters from the column headers.
LostKobrakai
That sounds like a bug / missing implementation in the parser of polars then.
LForCRLFare supposed to be allowed in quoted fields based on RFC 4180.alphydan
Removing all return characters leads to an import without errors.
is imported correctly. Does that mean that return characters are not allowed in headers, even with quotes?
return characters outside the header seem to be imported correctly. for example, if I have an element of the csv be
Tiger and \nBeasts, but no returns in the header I can see:BradS2S
Yes you want it on a single line. That parsing error means they don’t expect labels to be on more than one line