如何以编程方式创建带有内容的Google文档电子表格?(How to programmatically create a Google Docs spreadsheet WITH CONTENT?)
我发现了多个有关如何使用Google Spreadsheets API或旧版API创建或编辑Google Doc电子表格的StackOverflow问题。 然而,这个Spreadsheets API似乎是“gdata”库的一部分,我的理解已被弃用。
较新的StackOverflow答案显示了如何使用Drive API创建一个空电子表格,这看起来更加流行。 但是,通过查看该API的文档和示例,它似乎只允许您使用电子表格MIME类型创建新的EMPTY文件。 我还没有找到任何用于创建具有实际内容的电子表格的功能(即行,列,工作表等)。
目前用于创建新的Google Doc电子表格并用内容填充它的过程是什么? Drive API是否具有我不理解的功能? 毕竟,“gdata”库(或至少它的Spreadsheets API部分)是否完全不推荐使用? 有没有第三种方法我完全错过了? 我正在使用Java代码,尽管我确信任何Python API都会有Java等价物。
I have found multiple StackOverflow questions dealing with how to create or edit Google Doc spreadsheets using the Google Spreadsheets API, or older API's. However, this Spreadsheets API seems to be part of the "gdata" library, which to my understanding is deprecated.
Newer StackOverflow answers show how to create an empty spreadsheet using the Drive API, which seems more current. However, from looking at the documentation and examples for that API, it seems to only let you create new EMPTY files with the spreadsheet MIME type. I have not found any functionality for creating a spreadsheet with actual content (i.e. rows, columns, worksheets, etc).
What is the current process for creating a new Google Doc spreadsheet AND populating it with content? Does the Drive API have functionality that I'm not understanding? Is the "gdata" library (or at least its Spreadsheets API portion) not completely deprecated after all? Is there some third approach that I've missed altogether? I'm working with Java code, to the extent that matters, although I'm sure that any Python API would have a Java equivalent.
原文:https://stackoverflow.com/questions/21217995
最满意答案
即使官方文档给出了
CSVREAD('classpath:/org/acme/data/address.csv')
例子, Sean Patrick Floyd建议删除主要的斜杠,即:CREATE TABLE T_FOO ( ... ) as select * from CSVREAD('classpath:foo.csv');
这是行得通的 !
Even if the official docs give the
CSVREAD('classpath:/org/acme/data/address.csv')
example, Sean Patrick Floyd suggested to remove the leading slash, i.e. having:CREATE TABLE T_FOO ( ... ) as select * from CSVREAD('classpath:foo.csv');
and this is working!
相关问答
更多-
即使官方文档给出了CSVREAD('classpath:/org/acme/data/address.csv')例子, Sean Patrick Floyd建议删除主要的斜杠,即: CREATE TABLE T_FOO ( ... ) as select * from CSVREAD('classpath:foo.csv'); 这是行得通的 ! Even if the official docs give the CSVREAD('classpath:/org/acme/data/address.cs ...
-
最后我解决了我的问题...... 从1.4.x开始,H2使用MV_STORE(请参阅此处回答和Thomas Mueller评论)。 显然,Web控制台试图自动附加一个.mv.db扩展名。 即使已经有一个带有h2.db扩展名的文件。 所以,我将我的代码的H2版本从1.3.175升级到1.4.178,最后,我可以看到我的数据... 编辑 这是@devdanke提出的另一种解决方案: 您必须手动告诉H2 1.4.x不要使用MV_Store:“; mv_store = false”。 真是麻烦。 例如,您将以类似于 ...
-
您可以使用RUNSCRIPT SQL语句 : RUNSCRIPT FROM 'test.sql' 或者您可以使用RunScript独立/命令行工具 : java -cp h2*.jar org.h2.tools.RunScript -url jdbc:h2:~/test -script test.sql 您还可以在应用程序中使用RunScript工具: RunScript.execute(conn, new FileReader("test.sql")); You can use the RUNSCR ...
-
您必须将DatabaseH2插件包含在产品中包含的插件列表中。 由于您使用的是基于特征的产品,因此您应该在功能fpFeature列出它。 在fpFeature打开feature.xml并添加DatabaseH2插件。 You must include the DatabaseH2 plugin in the list of plugins included in the product. Since you are using a feature based product you should list ...
-
如果你有H2控制台,你可以基本上创建一个新的数据库,无论你想要的。 如果你仔细阅读h2 faq,他们会很好地描述你如何做到这一点。 使用jdbc:h2:〜/ test等数据库URL时,数据库存储在用户目录中。 对于Windows,这通常是C:\ Documents and Settings \或C:\ Users \。 如果未设置基目录(如在jdbc:h2:./ test中),则数据库文件存储在启动应用程序的目录(当前工作目录)中。 从开始菜单使用H2控制台应用程序时,这是/ bin。 基本目录可以在数据库 ...
-
H2数据库损坏(H2 database corruption)[2023-09-16]
要检查数据库文件是否存在,您可以使用 if (new java.io.File(databaseFileName).exists()) { ... } 如果文件存在,但数据库已损坏,那么通常您将无法连接到它(尝试连接将抛出异常)。 这是我所知道的最快验证方式。 数据库文件存在的风险很小,但尚未完全初始化。 如果是这种情况,则某些表不存在。 验证所有表存在的标准方法是使用DatabaseMetaData.getTables 。 但是,除非您使用某些危险的功能(例如禁用事务日志或禁用数据库文件锁定),否则数据 ... -
CSVREAD函数支持带和不带列标题的文件。 如果文件包含列标题,则不要在该函数中提供列列表,例如: SELECT * FROM CSVREAD('test.csv'); SELECT * FROM CSVREAD('data/test.tsv', null, 'rowSeparator=' || CHAR(9)); 如果文件不包含列标题,则在函数调用中提供列列表,例如: SELECT * FROM CSVREAD('test2.csv', 'ID|NAME', 'charset=UTF-8 fieldS ...
-
INNER JOIN与h2数据库和postgresql数据库的区别(INNER JOIN differences with h2 database and postgresql database)[2022-03-15]
假设您在H2和Postgres中使用相同的基础数据运行相同的ANSI兼容查询,您应该得到相同的结果。 在任一数据库中, INNER JOIN的行为都没有什么不同。 但是在代码转储中快速搜索ORDER BY表明您没有在查询中进行任何排序。 我注意到Postgres巧合似乎是在data1列上排序,而H2似乎根本没有排序。 我建议结果集从未排序集的角度来看是相同的。 通常,如果您希望在结果集中进行cetain排序,则需要在生成该数据的查询中使用ORDER BY 。 因此,如果您将ORDER BY data1添加到 ... -
要使用其他数据库(例如MySQL),需要在安装服务之前将这些数据库的JDBC驱动程序的位置添加到环境变量H2DRIVERS或CLASSPATH中。 可以设置多个驱动程序; 每个条目需要分开; (Windows)或:(其他操作系统)。 支持路径名中的空格。 不得引用设置。 To use other databases (for example MySQL), the location of the JDBC drivers of those databases need to be added to the ...
-
您可以直接使用CSV工具,而无需打开数据库 : Csv csv = new Csv(); csv.setOptions("fieldSeparator=,"); String fileName = "/home/testuser/csvfile.csv"; ResultSet rs = csv.read(fileName, null, null); while (rs.next()) { // processing data... } rs.close(); You can use the CSV ...