Thursday, 15 July 2010

io - How to read in data structures from file in Erlang? -



io - How to read in data structures from file in Erlang? -

i going through exercise requires me continually reuse info structures in erlang when testing applications , getting bit laborious. saving them easy plenty with

file:write_file(path, data).

however struggling read info in, read_file , read_lines seem create things unnecessarily complicated , not through lack of searching, haven't found way ready construction in erlang, although have seen extensive csv , xml parsers. sense there must easy way don't know terminology. far have:

parse(filename) -> {ok, data} = file:read_file(filename), binary:split(data, [<<"\n">>], [global]).

any help appreciated.

you’re right, there easy way:

file:consult(“../filepath/file.txt”).

more info on theerlang docs

data-structures io erlang readfile

No comments:

Post a Comment