N
N
Noticson2021-03-12 20:20:18
Google Sheets
Noticson, 2021-03-12 20:20:18

How to remove "0" at the beginning of a value in a Google spreadsheet when using the =IMPORTXML function?

The value is written to the Google table cell through the =IMPORTXML function, which is taken from the site shikimori.one. If the value is a decimal fraction with a zero after the decimal point, then a zero is also added to the beginning of the value (see screenshot). If the decimal point is followed by any number other than zero, then the value does not change (i.e. zero is not added to the beginning of the value). The question is how to set up the data format in such a cell so that the value never starts from zero?
604ba257b922f560296975.png

=IMPORTXML("https://shikimori.one/animes/40935-beastars";"//*[@id='animes_show']/section/div[1]/div[2]/div/div/div[1]/div[1]/div[2]/div/div[2]/div[1]/div[2]/div/div[2]/div[1]")

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Grigory Boev, 2021-03-12
@Noticson

It interprets it as a date. Here is a crutch that will help:

=REGEXEXTRACT( join("|";IMPORTXML("https://shikimori.one/animes/40935-beastars";"//*[@id='animes_show']/section/div[1]/div[2]/div/div/div[1]/div[1]/div[2]/div/div[2]/div[1]/div[2]/div/div[2]//text()"));"0?(.*?)\|.*")

We take the data one level higher, combine it through "|", isolate the necessary data with a regular expression.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question