Scan a google document line by line

早过忘川 提交于 2020-01-15 03:26:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!