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

create-glossary-from-spreadsheet.js 754 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
26
27
28
29
30
31
32
33
34
35
36
  1. #!/usr/bin/env node
  2. // [start-readme]
  3. //
  4. // This script turns a Google Sheets CSV spreadsheet into a YAML file.
  5. //
  6. // [end-readme]
  7. const fs = require('fs')
  8. const path = require('path')
  9. const yaml = require('js-yaml')
  10. const inputFile = path.join(__dirname, '../data/glossary.yml')
  11. const glossary = yaml.load(fs.readFileSync(inputFile, 'utf8'))
  12. console.log(glossary)
  13. const external = []
  14. const internal = []
  15. glossary.forEach(term => {
  16. if (term.internal) {
  17. delete term.internal
  18. internal.push(term)
  19. } else {
  20. external.push(term)
  21. }
  22. })
  23. fs.writeFileSync(
  24. path.join(__dirname, '../data/glossaries/internal.yml'),
  25. yaml.dump(internal)
  26. )
  27. fs.writeFileSync(
  28. path.join(__dirname, '../data/glossaries/external.yml'),
  29. yaml.dump(external)
  30. )
Tip!

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

Comments

Loading...