sahilpaudel

sahilpaudel OP

gist

I am trying to read a CSV file that has single column URL with multiple corresponding URLs for the same.
Library: nimble_csv

I have attached gist file url of the code.
I am able to read the urls from the file.

The problem I am facing is while I am iterating urls using Enum.each so I wanted to know that if one iteration fails inside Enum.each function, how can I handle that as like for this url the processing failed or for 2 iteration I want to send response that this two url is not processed.

First 3 of 3 Posts Switch mode

ryanzidago

ryanzidago

Inside the Enum.each/2 function, you could insert a case statement?

Enum.each(urls, fn url ->
  case try_parse_url(url) do
    url -> url
    {:error, unprocessed_url -> append_to_the_list_of_unprocessed_urls(unprocessed_url)
end)

where the function try_parse_url/1 do some kind of pattern matching against a binary string to check if it is a proper URL or not and if not, then the unprocessed URL is appended to some kind of list.

What do you think?

sahilpaudel

sahilpaudel OP

Hey @ryanzidago,
Thanks for the reply will surely try this.

ryanzidago

ryanzidago

How did it go?

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
silverdr
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated! To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead. Sta...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
roeland
Kia ora, We have been using elixir-google-api to connect to Google Drive. However, with the updates to Tesla due to CVEs this is now bro...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
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
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New

We're in Beta

About us Mission Statement