逐行扫描Google文档 [英] Scan a google document line by line

查看:87
本文介绍了逐行扫描Google文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,基本上,我正在尝试使用node.js扫描google文档,然后如果其中有ROBLOX ID就会对其进行跟踪。当它跟踪它时,如果它加入了id列表中的组之一,它将自动将其放行。

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.

有什么帮助吗?

我在逐行扫描Google文档时有些卡住。

I'm a little stuck on the scanning a google document line by line.

推荐答案

我不确定如何从Google文档中进行操作,但是如果您愿意使用文本文件( .txt ),我认为我可以帮忙。

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.

使用Node FS,我们可以使用行读取器

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

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

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.

这篇关于逐行扫描Google文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆