Cannot read a csv file into a defstruct

I tried to read a csv file with the next snippet of code

NimbleCSV.define(MyParser, separator: "\,", escape: "\"")
  results =!("/home/thiel/contributie4.csv")

  |> MyParser.parse_stream
  |> [productcode, relatiecode, volledige_naam, voornaam, geboortedatum, product, persoonscode, contrib_cat] -> 
      productcode:    :binary.copy(productcode),
      relatiecode:    :binary.copy(relatiecode),
      volledige_naam: :binary.copy(volledige_naam),
      geboortedatum:  :binary.copy(geboortedatum),
      product:        :binary.copy(product),
      persoonscode:   :binary.copy(persoonscode),
      contrib_cat:    :binary.copy(contrib_cat) 


and I got the next error message:

== Compilation error in file test/fcb_test.exs ==
** (ArgumentError) cannot invoke def/2 inside function/macro
    (elixir) lib/kernel.ex:5238: Kernel.assert_no_function_scope/3
    (elixir) lib/kernel.ex:4155: Kernel.define/4
    (elixir) expanding macro: Kernel.def/2
    test/fcb_test.exs:165: FcbTest."test qdata with convert"/1
    (ex_unit) expanding macro: ExUnit.Case.test/2
    test/fcb_test.exs:165: FcbTest."test qdata with convert"/1
    (elixir) lib/kernel/parallel_compiler.ex:237: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/7

Can anyone explain what I did wrong?

Thanks in advance

In the file test/fcb_test.exs, you are probably calling def/2 inside of a test.

Hi Nobz,

Many thanks!
You were right!
I made an typo.
Very frustating not seeing it.