shansiddiqui94

shansiddiqui94 OP

Hey Guys,

Offer Accepted: No

So I was contacted a few weeks ago about this position. The role was for a junior developer with experience in engineering. Who would be willing to learn Elixir or grow with existing knowledge. Essentially the client who is using Erlang wanted to move over to Elixir.

I gave the interview one week in advance before my flight to Turkey, I also advised the CTO of my flight and time away. The CTO gave me a take-home written in Elixir assignment the day before my flight.

The Take Home:
The take-home was a bit more of a challenge than I had expected it would be. I was required to build and design a CSV parser. Below are the requirements for the task

You will design and build a module/function that parses
a CSV file and applies a 2-arity Fun, record by record.

All your work should take place in a git repository.

Please take care to document/test your code.

The processing of the file should take care to not
consume excessive memory.

The parser should conform to RFC 4180 https://www.rfc-editor.org/rfc/rfc4180

The entry point should be a 4-arity function with parameters:
  a) File
  b) Fun (the fun to be applied to each valid row)
  c) Separator (default to comma)
  d) Maximum Error Count (default 0)

For simplicity sake:

  a) Treat the first row of the CSV as the header
  b) The Fun being passed should convert
     the received data into a map with keys being the
     values of the CSV header row and print them to stand out.

Error rows should be accumulated, should parsing
complete with less than the Maximum Error Count,
return the error rows with the reasons.

Please do not spend more than 2 hours on the task.

Personally I have never done anything like this before. I began to research and ask around how to attempt this. The reddit community told me that building a CSV parser without a framework is not recommended. So I attempted and didn’t get very far. My answers below

defmodule ParserProj22 do

  def entry_point(file, format_data, separator \\ ",", max_error_count \\ 0 ) do
    file
      |> Stream.file!

  end

  def format_data([headers | row] = data) do
    map = 
      headers
      |> Enum.zip(row)
      |> Enum.into(%{}) 
      
      IO.puts(map)
  end
end

# Map.new([{:b, 1}, {:a, 2}])

As you can see I didn’t get very far. How else could I have solved this problem?
Thank you for hearing me out, I understand the company wanted to see where I was at. However, I did advise them That I did not do Elixir professionally

First Post! Switch mode

dimitarvp

dimitarvp

Alright then, let’s start small. Given you have this string:

text = "111,222,333"

How would you transform that to [111, 222, 333]?

— All posts loaded —

Where Next? Top

Trending in Discussions Top

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 91898 914
New
AstonJ
The obligatory hello world thread! Who are you and where are you from? :stuck_out_tongue:
4616 55835 594
New
byu
@chrismccord : I just saw the Extract AGENTS.md from Phoenix.new into phx.new generator commit to the phoenix project. My initial shotgu...
New
arcanemachine
I was working on an Ecto migration and I needed a timestamp. So, for the nth time, I looked up the different data types for timestamps, a...
New
AstonJ
Just a general thread to post chat/news/info relating to AI/ML stuff that may be relevant for Nx now or in the future. Got anything to sh...
New
juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
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

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
mudasobwa
While I am working on the Language Agnostic Code Audit SaaS, which uses MetaAST (spoiler: I am expecting it to be in a good shape for ann...
New

We're in Beta

About us Mission Statement