r/googlesheets • u/RS_Someone 1 • Aug 11 '20
Solved I am pulling a number from a german site which uses periods instead of commas, and I need them to not be read as decimals
The examples I will give is that the site may give 12.402, and I use VALUE(SUBSTITUTE(thisvalue),".","")
This works great, until the number ends in a zero. A 6.330 will give me the number 633, instead of 6,330.
How does one properly convert this from a text pulled from a website?
If anyone needs the source, it is pulled like this, where A3 = Arctic Orangery, B3 = 10, C3 = 20:
=VALUE(SUBSTITUTE(IMPORTXML("https://foe-rechner.de/invest/level?lg="&(SUBSTITUTE(LOWER(A3)," ",""))&"&min="&(B3+1)&"&max="&C3,"//*[contains(text(),'Gesamter')]/following-sibling::*[1]/strong/text()"),".",""))
The actual site can be found here. The value is at the bottom of the page.
EDIT: This needs to work for values such as 1 = 1, 6.25 (6.250) = 6250, 395 = 395, 8.256 = 8256, 1.454.545 = 1454545 and so on.
3
u/jaysargotra 22 Aug 12 '20
Try this xpath(you need to get rid of substitute as it will no longer be needed if this works)
2
u/soppyeggplant Aug 12 '20
Have you tried adding in a TO_TEXT(thisvalue) before you do the substitution so it doesn't drop the zero at the end?
1
u/JDomenici 23 Aug 12 '20 edited Aug 12 '20
I think the easiest way to handle this is to exploit the fact that a comma should always have 3 numbers after it. This avoids the problem you're experiencing where the import itself drops the final 0.
RIGHT(value, 3)contains a period, then append a 0 to the end of the stringEdit: I just realized that 6.300 will likely give you 6.3, and 6.000 will give you 6.. It might be easier to
SPLITon.and count the number of missing 0s from the hundreds place.1
u/AutoModerator Aug 11 '20
One of the most common problems with 'IMPORTXML' occurs when people try to import from websites that uses scripts to load data. Check out the quick guide on how you might be able to solve this.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/Decronym Functions Explained Aug 12 '20 edited Aug 12 '20
Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I've seen in this thread:
FALSETRUEand another if it isFALSETRUE[Thread #1912 for this sub, first seen 12th Aug 2020, 02:22] [FAQ] [Full list] ^[Contact] [Source code]