【问题标题】:How do I change imported data from decimals to commas in Google Sheets?如何在 Google 表格中将导入的数据从小数更改为逗号?
【发布时间】:2020-04-19 17:53:40
【问题描述】:

使用=IMPORTHTML 函数,我将数据从网站导入到谷歌表格。我要从中导入的页面是:https://www.tools4albion.com/refining.php?cat=ore&city=5&quantity=80&skillT4=28&skillT7=0&return=5&tax_sell=6&tax_shop=30&skillT5=17&skillT8=0&tax_order=1.5&skillT6=1,但是该网站使用小数而不是逗号来分隔数字(不要与“0.2”等小数混淆)。在 Google 表格上查看时,会产生 2 个问题:

  1. 带有三位小数的数字会自动对齐到左侧,而不是通常的右侧。

  1. 它留下了一些非常重要的数据缩进,这完全改变了它的值(该值应该是 545760,但谷歌表格显示为 545.##)

  2. 不能对三进制数据执行任何计算、函数或算术运算。即使是带小数的那些也被视为小数而不是整数。

对于那些想尝试的人,我使用了公式:

=IMPORTHTML("https://www.tools4albion.com/refining.php?cat=ore&city=5&quantity=80&skillT4=28&skillT7=0&return=5&tax_sell=6&tax_shop=30&skillT5=17&skillT8=0&tax_order=1.5&skillT6=1","table",5)

关于如何解决此问题的任何想法?如果 Google 表格上没有这样的解决方案。使用 Microsoft Excel 执行此操作没有问题。两种软件的答案对我来说都很好。

【问题讨论】:

    标签: xml google-sheets google-sheets-importxml


    【解决方案1】:

    尝试:

    =ARRAYFORMULA(IF(REGEXMATCH(""&IMPORTHTML(
     "https://www.tools4albion.com/refining.php?cat=ore&city=5&quantity=80&skillT4=28&skillT7=0&return=5&tax_sell=6&tax_shop=30&skillT5=17&skillT8=0&tax_order=1.5&skillT6=1",
     "table", 5), "\d+\.\d+\.\d+$|\d+\.\d+$"), SUBSTITUTE(IMPORTHTML(
     "https://www.tools4albion.com/refining.php?cat=ore&city=5&quantity=80&skillT4=28&skillT7=0&return=5&tax_sell=6&tax_shop=30&skillT5=17&skillT8=0&tax_order=1.5&skillT6=1",
     "table", 5), ".", )*1, IMPORTHTML(
     "https://www.tools4albion.com/refining.php?cat=ore&city=5&quantity=80&skillT4=28&skillT7=0&return=5&tax_sell=6&tax_shop=30&skillT5=17&skillT8=0&tax_order=1.5&skillT6=1",
     "table", 5)))
    

    【讨论】:

    • 嗨,这解决了大部分问题。但是,问题 1(在我原来的帖子中)仍然存在。我还不能将此答案标记为正确答案,有没有办法改变公式来解决问题#1?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-12
    • 2023-01-01
    相关资源
    最近更新 更多