逐行扫描谷歌文档

时间:2018-05-28 06:11:07

标签: node.js google-docs google-docs-api discord.js roblox

所以基本上,我正在尝试使用node.js来扫描谷歌文档,然后如果一个ROBLOX ID在那里它跟踪它。当它跟踪它时,如果它加入id列表中的一个组,它会自动放出它。

有任何帮助吗?

我有点坚持扫描谷歌文档。

1 个答案:

答案 0 :(得分:3)

我不确定如何从谷歌文档中做到这一点,但如果你愿意使用文本文件(.txt),我想我可以提供帮助。

使用节点FS,我们可以使用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!')
  })
})

所以上面的代码是在typescript中,但是typescript可以编译成javascript。如果此代码对您不起作用,我至少希望它能提供一些帮助您找到答案的知识。