首页 > 解决方案 > 过滤 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)

IMPORTHTML 原文: 在此处输入图像描述

预期格式:
在此处输入图像描述 ---在此处输入图像描述

标签: google-sheetsgoogle-sheets-formulagoogle-sheets-querygoogle-sheets-importxml

解决方案


您可以在一个公式中将 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)}

公式如何工作:

  1. 正如您所注意到的,这两个查询的数据部分在它们中都是相同的。实际上不同的是“我们从查询中要求的内容”
  2. 在第一个我们使用"select Col1 where Col2 is null and not Col1 contains '*'"
  3. 在第二个"select Col1, Col2, Col3, Col4 where Col2 is not null label Col1 'Time'"
  4. 我们通过将它们连接在一起来创建一个数组,如下所示={1stQUERY,2ndQUERY}

在此处输入图像描述


推荐阅读