问题
so basically, I'm trying to use node.js to scan a google document, then if a ROBLOX id is on there it tracks it. When it tracks it, if it joins one of the groups in the id list, it auto-exiles it.
Any help?
I'm a little stuck on the scanning a google document line by line.
回答1:
I am not sure about how to do it from a google doc, but if you are willing to move to using text files(.txt
) I think I could be of assistance.
Using Nodes FS we can read lines using a Line reader
import * as fs from 'fs'
import { createReadStream } from 'fs'
import { createInterface } from 'readline'
const lineReader = createInterface({
input: createReadStream('data/input.txt')
})
const output: string[] = []
lineReader.on('line', (item: string) => {
output.push(If you wanna output something to an output file put it here)
})
// Down here is the output of what you put in the output.push
lineReader.on('close', () => {
fs.writeFile('data/output.txt', output.join('\n'), err => {
if (err) throw err
console.log('The file has been saved!')
})
})
So the above code is in typescript, but typescript can be compiled down into javascript. If this code doesn't work for you I at least hope it gave some knowledge that helped you find your answer.
来源:https://stackoverflow.com/questions/50560129/scan-a-google-document-line-by-line