在Google Apps脚本中从类似csv的文件中读取数据 [英] read data from csv-like file in Google Apps Script

查看:109
本文介绍了在Google Apps脚本中从类似csv的文件中读取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows脚本文件(不是Google Apps脚本),它将数据输出到文本文件。此文件包含以逗号分隔的数字(如CSV文件,但以编程方式创建)。我可以在Excel中以CSV文件的形式打开它。该文件存储在我的Google云端硬盘上。
我想编写一个每天运行的Google Appscript,并以逗号分隔的数字打开此文本文件,并将数据显示在一个Appscript图表中。



在Apps脚本,如何从这个文本文件读取数据?它看起来像SpreadsheetApp不适用于文本文件,数据之间用逗号分隔,而仅在Google表格文件中分隔。这是真的?如何从我的文本文件中读取这些数据,并用逗号分隔数字? 解决方案

除了上面的答案,也可以使用GAS中Utilities的内置CSV解析器: GAS-parseCsv


I have a Windows script file (not a Google Apps Script though) that outputs data to a text file. This file has numbers separted by commas (like a CSV file but is created programatically). I can open this in Excel as a CSV file. This file is stored on my Google Drive. I want to write a Google Appscript that runs each day and opens this text file with numbers separated by commas and displays the data in an Appscript chart.

In Apps Script, How to read in the data from this text file? It looks like the SpreadsheetApp does not work with on a text file with data separated by commas but rather only on Google Sheets files. Is this true? How can I read in this data from from my text file with numbers separated by commas?

解决方案

Apart from the answers above, you could also use the inbuilt CSV parser from Utilities within GAS: GAS-parseCsv

这篇关于在Google Apps脚本中从类似csv的文件中读取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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