3 ms·
The only thing prevents me using prolog for proper tasks is not getting its IO: reading/writing files: csv, json. Any cool (video) tuts on it? I searched a lot
by pezo1919 7y ago
The only thing prevents me using prolog for proper tasks is not getting its IO: reading/writing files: csv, json.
Any cool (video) tuts on it? I searched a lot but did not find anything "easy".
- hjek 7y agoSay 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