def xlsx_to_tsv(xlsx_file_name) when is_binary(xlsx_file_name) do
tsv_file = File.open!(tsv_file_name(xlsx_file_name), [:write])
Excellent.parse(xlsx_file_name, 0)
|> CSV.encode(separator: ?\t)
|> Enum.each(&IO.write(tsv_file, &1))
end
def tsv_file_name(file_name) when is_binary(file_name) do
base = Path.basename(file_name, ".xlsx")
dir = Path.dirname(file_name)
Path.join(dir, "#{base}.tsv")
end
1) test xlsx_to_tsv (MyImporterTest)
test/my_importer_test.exs:14
** (MatchError) no match of right hand side value: {:error, {:EXIT, {{:badmatch, "c:/Users/myuser/Projects/my_importer/test/fixtures/myexcelfile.xlsx"}, [{:zip, :binary_io, 2, [file: 'zip.erl', line: 1724]}, {:zip, :get_end_of_central_dir, 3, [file: 'zip.erl', line: 1313]}, {:zip, :get_central_dir, 3, [file: 'zip.erl', line: 1269]}, {:zip, :do_unzip, 2, [file: 'zip.erl', line: 380]}, {:zip, :unzip, 2, [file: 'zip.erl', line: 370]}, {Excellent, :file_content, 2, [file: 'lib/excellent.ex', line: 57]}, {Excellent, :parse, 2, [file: 'lib/excellent.ex', line: 12]}, {MyImporter, :xlsx_to_tsv, 1, [file: 'lib/my_importer.ex', line: 8]}, {MyImporterTest, :"test xlsx_to_tsv", 1, [file: 'test/my_importer_test.exs', line: 18]}, {ExUnit.Runner, :exec_test, 2, [file: 'lib/ex_unit/runner.ex', line: 294]}, {:timer, :tc, 1, [file: 'timer.erl', line: 166]}, {ExUnit.Runner, :"-spawn_test/3-fun-1-", 3, [file: 'lib/ex_unit/runner.ex', line: 242]}]}}}
stacktrace:
lib/excellent.ex:57: Excellent.file_content/2
lib/excellent.ex:12: Excellent.parse/2
(my_importer) lib/my_importer.ex:8: MyImporter.xlsx_to_tsv/1
test/my_importer_test.exs:18
--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/c6f0e5e4-6ae6-42b2-bf8c-d60f0cef08b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/CAPhAwGz-cj%3Dqa5wR9aS%2BKDo3%2BbtdbF9wsE1vD%2BBf%2Bo-4RZ%2BmCg%40mail.gmail.com.
--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/92ade85e-b877-491c-9523-17682df27c6a%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/CAPhAwGwizuyMjf2jmUiduF_a5pj6SZ%2B4ne%3DoZ7V72L9fzk%3Dtcw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
** (throw) {:EXIT, {:badarg, [{:re, :run, [nil, {:re_pattern, 1, 0, 0, <<69, 82, 67, 80, 131, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 255, 255, 255, 255, 255, 255, 255, 255, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 64, 0, 0, 0, ...>>}, [{:capture, :all, :index}, :global]], [file: 're.erl', line: 729]}, {Regex, :do_replace, 4, [file: 'lib/regex.ex', line: 485]}, {Excellent, :calculate_type, 2, [file: 'lib/excellent.ex', line: 136]}, {Excellent, :event, 3, [file: 'lib/excellent.ex', line: 68]}, {:xmerl_sax_parser_utf8, :event_callback, 2, [file: 'xmerl_sax_parser_utf8.erl', line: 3308]}, {:xmerl_sax_parser_utf8, :parse_attributes, 3, [file: 'xmerl_sax_parser_utf8.erl', line: 797]}, {:xmerl_sax_parser_utf8, :parse_document, 2, [file: 'xmerl_sax_parser_utf8.erl', line: 185]}, {:xmerl_sax_parser_utf8, :parse, 2, [file: 'xmerl_sax_parser_utf8.erl', line: 117]}, {Excellent, :parse, 2, [file: 'lib/excellent.ex', line: 14]}
John - It's been said many times here that a confusing error message is a bug. I don't think it is appropriate to call expressing confusion "complaining". I appreciate that you took the time to teach him how to decipher the message, but we shouldn't discourage people from expressing that initial confusion. That feedback, especially from people new to Elixir, is how we make things even better than they already are.
Maybe it's just me but I don't consider that error dramatically better than the stack trace you first showed. Both of them seem to contain a lot of noise in addition to the true problem. And in both cases, I'd be looking at the top of the stack and working my way down to the true issue.