Hi Herbert,
That script is a little too long and complicated for me.
Below is a script that is the same as above with a minimal addition of code to convert periods to commas for "European format" where the comma is used to designate decimals. This should produce the result that you want:
SG
(*
Retrieves stock quotes and other data from Yahoo! and places them in a Numbers table.
Place symbols in specified column starting at specified row number; no blanks; no footer row.
Retrieved data will be placed in columns immediately to the right of the symbols column.
By SGIII, 201403 v. 1.1
*)
--In the following line specify the types of data to retrieve in the order desired:
property quoteProperties : "l1r0e7e8s6"
(*
See https://code.google.com/p/yahoo-finance-managed/wiki/enumQuoteProperty
Example: last trade price followed by pe followed by this year's estimated EPS ==> "l1roe7"
*)
--In the following line change the default values in black as needed to target the desired table:
property t : {targetDoc:1, targetSheet:1, targetTable:1, symbolsColNum:1, symbolsStartRow:2}
(*
Example: To populate a table named "Quotes" in sheet "Portfolio A" in document "Investments" with symbols starting on row 2 of column B==>
{targetDoc:"Investments.numbers", targetSheet:"Portfolio A", targetTable:"Quotes",symbolsColNum:2, symbolsStartRow:2}
*)
property decSymbol : ","
tell application "Numbers" to tell document (t's targetDoc) to tell sheet (t's targetSheet) to tell table (t's targetTable)
tell column (t's symbolsColNum) to set symbConcat to my joinList(value of cells (t's symbolsStartRow as number) thru (count cells), "+")
try
set the clipboard to my commaToTab(my getYData(symbConcat, quoteProperties))
--add this line to convert decimals from . to , ("European format")
set the clipboard to my findReplace(the clipboard, ".", ",")
set pasteStr to the clipboard
on error
return --halt script if error getting Yahoo data
end try
set the selection range to cell (t'ssymbolsStartRow) of column ((t'ssymbolsColNum) + 1)
tell application "Numbers" to activate
tell application "System Events" to keystroke "v" using {option down, shift down, command down}
display notification "Stock data has been updated" with title "Numbers"
end tell
to getYData(qSymb, qProp) -- get Yahoo! data
try
set baseURL to "http://download.finance.yahoo.com/d/quotes.csv?"
set {symbStr, propStr} to {"s=" & qSymb, "&f=" & qProp}
set yData to do shell script "curl -s " & quoted form of (baseURL & symbStr & propStr)
if yData's text 1 thru 2 is "<!" then error --intercept Yahoo error page
if yData's text 1 thru 3 is "0.0" then error --a little more error-checking
return yData
on error
display alert "Trouble getting data from Yahoo! Check symbols. Ensure there are no blanks in the column and no footer rows, and that you have the right values in t's properties."
return
end try
end getYData
to joinList(aList, separator) --convert AS list to delimited string
set {oTid, AppleScript'stext item delimiters} to {AppleScript'stext item delimiters, separator}
set lstStr to aList as string
set text item delimiters of AppleScript to oTid
return lstStr
end joinList
to commaToTab(str) -- Numbers 3 wants tab-separated for pasting
try
set {oTid, AppleScript'stext item delimiters} to {AppleScript'stext item delimiters, ","}
set strLst to text items of str
set AppleScript'stext item delimiters to tab
set tsvStr to strLst as text
set AppleScript'stext item delimiters to oTid
return tsvStr
on error
display alert "Error!"
return
end try
end commaToTab
to findReplace(tt, f, r)
set {AppleScript'stext item delimiters, oTid} to {f, AppleScript'stext item delimiters}
set lst to text items of tt
set AppleScript'stext item delimiters to r
set tt to lst as string
set AppleScript'stext item delimiters to oTid
return tt
end findReplace
--end of script