Iex.new
Hi,
in our Team at work we have Hackathons and for next year I am thinking about to introduce Elixir. As we have todo with data processing in our daily work I planning to propose a small app that should import data in parallel from a huge csv file (let say for example a list of persons) into a database. And maybe to transform the data in between.
I think I would also like to show the results in the front end using Pheonix.
During my research I came across Flow and Broadway.
As I have not so much experience with Elixir and never used Flow/Broadway, what could be a good fit for my experimentation ?
I find this article on dev.to which seems to close to what I want to do :
Thank you!
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
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
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
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 47 to 38- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
Iex.new
Yes I will do that!
I will take care of that for my future posts
Sorry about that!
I already did it
Thank you all of you for your support!
dimitarvp
Looks like you don’t have a detection of duplicates so you’re constantly inserting the same records.
Your next step is to add an unique index on the name (or another field) to make sure you don’t duplicate so much.
And it would have been useful for you to mention your exact steps before. We’re not mind readers.
I consider this thread completed. Mark one of my answers as the solution (if you don’t mind) and if you have other problems, they are for a new thread IMO.
Iex.new
Thank you for giving me the command you use to load the file. After using the same command I can confirm that I came to the same result as you, It works!
That’s confirm my doubt in my previous comment :
How I proceed to run in this error:
2.1 mix ecto.drop
2.1 mix ecto.create
2.1 mix ecto.migrate
cp products.csv data/inIn the Elixir App, I have a “file watcher” that should check for new incoming files in the directory data/in. If a new file is detected, then it should be loaded by IngestCSV (see line #20. So I think this process is wrong defined/configured and seems infinite load the CSV-File…
dimitarvp
Man, this is getting tiring. Just drop the DB, create it again, run the migration, and then start the code.
And indeed as @D4no0 said, post some command output e.g.
mysql -e 'select count(id) from products;'before and after.The code I did is working perfectly, you are missing something else and I believe it’s time you get a grip and make it work.
Are you opening
iex -S mixand then runningIngestCSV.load("10_million_products.csv")? Is there any other code you’re not showing?D4no0
Command
ecto.migratedoes not delete old data, it runs the migrations otherwise if everything is up-to-date it does nothing.In your case you want to delete the entire database before inserting new data. This can be done by explicitly running
ecto.reset, orecto.dropfollowed byecto.createandecto.migrate.To have easier visibility on what happens in your database I would strongly recommend using a cli tool to query it, or even better a visual tool like dbeaver.
Iex.new
@dimitarvp, I have merged your modifications and then cloned the repo into a new local directory.
Afterward, I run the Ecto-migration with
mix ecto.migrate(so at that moment the tableproductsis empty)When the migration was finished I copied the CSV file into data/in.
I am very surprised at how fast the records are created in the database!
As you can see the number I got is much higher than the number of rows the file contains:
Maybe the file_watcher.ex is not properly configured (and the CSV file is endlessly loaded?)?
dimitarvp
You are sorted. Here is the PR: Make it work by dimitarvp · Pull Request #1 · pascal-chenevas/file_watch_example · GitHub
I made it use batch inserting again and it works just fine. Only takes 108 seconds on my Intel Mac to insert exactly 10 million records.
Try my branch on your machine and let us know. No reason not to work unless your MySQL instance is broken, or you are not showing all your code and something else in it is bugging it.
dimitarvp
You have a mistake in your data sample file. First line contains a shell prompt:
The rest is valid CSV.
dimitarvp
Dude, you have no database migration to create the table. Put one in! How can anyone help you if you haven’t took care to create the DB schema?
EDIT: I mean, it’s pretty simple, you should have included it:
dimitarvp
What MySQL engine are you using? Is it MariaDB or good old MySQL version? And what version?