Hi,
I tried to read a csv file with the next snippet of code
NimbleCSV.define(MyParser, separator: "\,", escape: "\"")
results =
File.stream!("/home/thiel/contributie4.csv")
|> MyParser.parse_stream
|> Stream.map(fn [productcode, relatiecode, volledige_naam, voornaam, geboortedatum, product, persoonscode, contrib_cat] ->
%Lid{
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)
}
end)
end
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