Skip to content

Instantly share code, notes, and snippets.

@kmaher9
Created September 4, 2018 18:13
Show Gist options
  • Save kmaher9/15111dc2182c7ee8d06db042b627ce2c to your computer and use it in GitHub Desktop.
Save kmaher9/15111dc2182c7ee8d06db042b627ce2c to your computer and use it in GitHub Desktop.
var businessFiles = fs.readdirSync(businessPath) // retrieve directory listing
var techFiles = fs.readdirSync(techPath)
for (var i = 0; i < businessFiles.length; i++) {
var file = businessFiles[i]
var content = fs.readFileSync(businessFiles + "\\" + file) // opens the file as a stream, reading the whole file into memory
inputs.push({input: content.toString(), output: 'business' }) // the entire file content is stored in a two dimensional array
}
for (var i = 0; i < techFiles.length; i++) {
var file = techFiles[i]
var content = fs.readFileSync(techFiles + "\\" + file)
inputs.push({input: content.toString(), output: 'tech' })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment