Erlang dets to txt

902 views Asked by At

How can i write information which store in dets to txt file?

Thank you.

2

There are 2 answers

0
JUST MY correct OPINION On BEST ANSWER

Since you've provided little to no information on what you mean or what you intend to do, the only advice I can give you is to read the dets manual. The functions you'll likely need are:

  • dets:open_file/1 or dets:open_file/2 to open the file that has the information in it.
  • dets:traverse/2 to walk over the data in your store passing in a fun that does whatever you want (in this case writing to a text file).
  • dets:close/1 to close the data store.

If you want more specific advice or if you're thinking of something entirely different you'll have to ask a better question—one that has details, for example.

1
shino On

An example of the answer by "JUST MY correct OPINION" is in "Mnesia User's Guide".

{ok, N} = dets:open_file(schema, [{file, "./schema.DAT"},{repair,false}, 
                                  {keypos, 2}]),
F = fun(X) -> io:format("~p~n", [X]), continue end,
dets:traverse(N, F),
dets:close(N).      

http://www.erlang.org/doc/apps/mnesia/Mnesia_chap7.html#id75830