【问题标题】:Scan a google document line by line逐行扫描谷歌文档
【发布时间】:2018-11-06 16:17:46
【问题描述】:

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

有什么帮助吗?

我在逐行扫描谷歌文档时有点卡住了。

【问题讨论】:

  • 你可以使用文本文件吗?如果是这样,我可能会在这里为您提供帮助。

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


【解决方案1】:

我不确定如何从 google 文档中执行此操作,但如果您愿意转而使用文本文件 (.txt),我想我可以提供帮助。

使用 Nodes 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!')
  })
})

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

【讨论】:

  • 感谢您的帮助。 :)
  • @ScratchCoder 如果它给了你你的答案或导致它记得接受它:)
  • 我还在测试它,所以我不确定它是否正确。
  • 是的,很好,我不确定你有多先进,但this is a compiler for typescript to javascript
猜你喜欢
  • 1970-01-01
  • 2023-03-24
  • 1970-01-01
  • 1970-01-01
  • 2023-04-07
  • 2018-03-18
  • 2016-05-01
  • 2012-04-21
  • 1970-01-01
相关资源
最近更新 更多