It strongly depend what you mean by splices it into a list, then create a tuple. Especially splice into list can take a lot of memory. One byte can occupy 16B if split into list. It is 5.6GB with easy.
EDIT:
Try this:
parse(File) ->
{ok, F} = file:open(File, [read, raw, binary]),
ok = parse(F, binary:compile_pattern([<<$,>>, <<$\n>>])),
ok = file:close(F).
parse(F, CP) ->
case file:read_line(F) of
{ok, Line} ->
parse_row_commodity_data(Line, CP),
parse(F, CP);
eof -> ok
end.
parse_row_commodity_data(Line, CP) ->
[ ReportingCountry, YearPeriod, Year, Period, TradeFlow, Commodity,
PartnerCountry, NetWeight, Value, IsReported]
= binary:split(Line, CP, [global, trim]),
true = ets:insert(memdatabase, {
{YearPeriod, ReportingCountry, Commodity},
{ ReportingCountry, Year, Period, TradeFlow, Commodity,
PartnerCountry, NetWeight, Value, IsReported}
}).