10 ms·
Say you have a file, `foo.json`, with the content: {"foo":"bar"} Run `swipl` and first load the JSON library: ?- [library(http/json)]. true. The
by hjek 7y ago
Say you have a file, `foo.json`, with the content:
{"foo":"bar"}
Run `swipl` and first load the JSON library:
?- [library(http/json)].
true.
Then open the file `foo.json` (in read mode) as Stream which JSON read translates to Term:
?- open('foo.json', read, Stream), json_read(Stream, Term).
Stream = <stream>(0x557f0cbfb1c0),
Term = json([foo=bar]).
(Both instances of `Stream` are the same because of unification.)
Say `foo.csv` containts:
foo,bar
Then go:
?- [library(csv)].
true.
?- csv_read_file("foo.csv",Rows).
Rows = [row(foo, bar)].
Triska's videos are quite theoretical. Anne Ogborn has a lot of good real world programming tutorials[0]. Can highly recommend the web app tutorial[1].
I don't know any good videos that cover this. I'm happy to help with what I can though, and I've also found the ##Prolog IRC on Freenode helpful.
[0]: http://www.pathwayslms.com/swipltuts/ http://www.pathwayslms.com/swipltuts/
[1]: http://www.pathwayslms.com/swipltuts/html/index.html http://www.pathwayslms.com/swipltuts/html/index.html