google-sheets - 过滤 IMPORTHTML 数据
问题描述
当我导入数据时,它采用这种格式(图 1),带有空格。我想知道是否有任何方法可以调整以使这些空白消失,如果有任何方法可以达到它们,那么预期的两个模型(图 2 和 3 )对我来说很重要。
记住所有的日期/
和所有的时间都有:
我试图从中过滤QUERY
,但是当试图让"Select Col1, Col2, Col4 Where Col2 is not null"
日期消失并且只剩下时间时,我尝试通过REGEXMATCH
使用将日期与时间分开/
,:
但我也没有成功。
我也通过 尝试过IMPORTXML
,但某些数据最终无法在网站的某些页面上正确导入,因为IMPORTHTML
这些错误不会发生。我使用的XML's
是:
"//tr[@class='no-date-repetition-new' and ..//td[@class='team team-a']] | //tr[@class='no-date-repetition-new live-now' and ..//td[@class='team team-a']]"
"//td[@class='team team-a']/a | //td[@class='team team-a strong']/a"
目前的公式如下:
=IMPORTHTML("https://int.soccerway.com/national/austria/1-liga/20192020/regular-season/r54328/","table",1)
解决方案
您可以在一个公式中将 2 个查询连接在一起(一个并排),以获得您的结果
={QUERY(IMPORTHTML("https://int.soccerway.com/national/austria/1-liga/20192020/regular-season/r54328/","table",1),
"select Col1 where Col2 is null and not Col1 contains '*'",1),
QUERY(IMPORTHTML("https://int.soccerway.com/national/austria/1-liga/20192020/regular-season/r54328/","table",1),
"select Col1, Col2, Col3, Col4 where Col2 is not null label Col1 'Time'",1)}
公式如何工作:
- 正如您所注意到的,这两个查询的数据部分在它们中都是相同的。实际上不同的是“我们从查询中要求的内容”
- 在第一个我们使用
"select Col1 where Col2 is null and not Col1 contains '*'"
- 在第二个
"select Col1, Col2, Col3, Col4 where Col2 is not null label Col1 'Time'"
- 我们通过将它们连接在一起来创建一个数组,如下所示
={1stQUERY,2ndQUERY}
推荐阅读
- javascript - 角垫输入
- sql-server - 确定 SQL 脚本中的字符数
- java - Cassandra 使用 LocalDate 截断毫秒
- mongodb - 如何在猫鼬中查找日期范围之间的数据
- html - 哪个是嵌套的正确 H* 标记
- c - 这个使用 Visual Studio 的简单 C 文件的奇怪行为会创建一个空列表('segmentation fault (core dumped)' - 'nullptr')
- python - 在 Python 中重新排列字段
- c# - 如何在实体框架中选择所有列和自定义列?
- java - Room DAO 无法从数据库中检索数据
- postgresql - postgres 用户限制架构更改