Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

goodreads.js 791 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  1. const fs = require('fs-extra');
  2. const zlib = require('zlib');
  3. const cp = require('child_process');
  4. function importTable(key, file) {
  5. let s = fs.createReadStream(file);
  6. let p = cp.spawn('psql', ['-c', `\\copy gr_${key} FROM STDIN`], {
  7. stdio: ['pipe', process.stdout, process.stderr]
  8. });
  9. s.pipe(zlib.createGunzip()).pipe(p.stdin);
  10. return p;
  11. }
  12. exports.importBooks = function() {
  13. return importTable('book', 'data/goodreads_books.json.gz');
  14. }
  15. exports.importInteractions = function() {
  16. return importTable('interactions', 'data/goodreads_interactions.json.gz');
  17. }
  18. exports.importWorks = function() {
  19. return importTable('work', 'data/goodreads_book_works.json.gz');
  20. }
  21. exports.importAuthors = function() {
  22. return importTable('author', 'data/goodreads_book_authors.json.gz');
  23. }
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...