本文與 Linux 無關;這是關於使用JMP下載貨幣換算資料。
Linux 計算器上的貨幣按鈕最近吸引了我的注意。
Calculator showing the currency conversion buttonsCalculator showing the currency conversion buttonsCalculator showing the currency conversion buttonsCalculator showing the currency conversion buttons顯示貨幣轉換按鈕的計算器
他們如何獲得最新的換算係數? 谷歌帶我去這裡,這讓我這裡,這帶我去此歐洲央行頁面包含費率以及 PDF、CSV 和 XML 下載連結。 點擊 XML 鏈接,您的瀏覽器可能會打開如下所示的內容:
screenshot of FireFox showing an XML file of exchange ratesscreenshot of FireFox showing an XML file of exchange ratesscreenshot of FireFox showing an XML file of exchange ratesscreenshot of FireFox showing an XML file of exchange rates顯示匯率 XML 檔案的 FireFox 螢幕截圖
快速瀏覽一下就會發現這些匯率都是基於歐元,因為歐元沒有出現,而且表中沒有 1.0000 因子。 參考頁面也是這麼說的:
based on the eurobased on the eurobased on the eurobased on the euro基於歐元
讓我們將 XML 載入到資料表中。 JMP 15 的 XML 精靈可以協助建置 JSL 來執行此操作。 首先,將 XML 從瀏覽器儲存到您的計算機,然後使用“文件”->“開啟”,選擇 XML 副檔名,選擇您的文件,然後在精靈中開啟它。
Choose the XML extension to see the downloaded fileChoose the XML extension to see the downloaded fileChoose the XML extension to see the downloaded fileChoose the XML extension to see the downloaded file選擇 XML 副檔名以查看下載的文件
XML 精靈打開,是時候決定哪些列和行是有趣的。 打開統計列以查看重複資料位於哪些鍵下,並關閉名稱列以使顯示更適合螢幕:
opening the XML file with the wizardopening the XML file with the wizardopening the XML file with the wizardopening the XML file with the wizard使用精靈開啟 XML 文件
您也可以使用 Tall Guess 來獲得相同的結果。 高個猜測注意到 32 個重複條目並選擇該鍵來產生行,然後選擇所有(兩個)子鍵來產生列。 它使用採樣器資料來確定子鍵是否應產生數字資料或字元資料。
現在,透過關閉統計列並重新開啟名稱列來重新命名列。 也修改一些其他內容,將「貨幣」的建模類型設為「名義」。 時間、姓名、主題都在圖片後面描述了...
Changing column names, adding some meta dataChanging column names, adding some meta dataChanging column names, adding some meta dataChanging column names, adding some meta data更改列名稱,添加一些元數據
還有其他三列元資料:時間、名稱、主題。 時間似乎是最有用的;讓我們保留每一行的時間。 姓名和主題只能保留為表變數;確定後他們會出現:
The source script and the two table variables are part of the imported tableThe source script and the two table variables are part of the imported tableThe source script and the two table variables are part of the imported tableThe source script and the two table variables are part of the imported table來源腳本和兩個表變數是導入表的一部分
按一下要提醒的表變量,該表來自何處。
若要在下週使用下週的當前資料重現此匯入,請取得來源腳本並在 URL 中進行編輯:
Open(
//"E:\eurofxref-daily.xml",
"https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml",
XML Settings( Stack( 0 ),
Row( "/gesmes:Envelope/Cube/Cube/Cube" ),
Col("/gesmes:Envelope/gesmes:subject",
Column Name( "gesmes:subject" ), Fill( "Use Forever" ),
Type( "Table Variable" ), Format( {"Best"} ), Modeling Type( "Continuous" ) ),
Col("/gesmes:Envelope/gesmes:Sender/gesmes:name",
Column Name( "gesmes:name" ), Fill( "Use Forever" ),
Type( "Table Variable" ), Format( {"Best"} ), Modeling Type( "Continuous" ) ),
Col("/gesmes:Envelope/Cube/Cube/@time",
Column Name( "time" ), Fill( "Use Forever" ),
Type( "Numeric" ), Format( {"yyyy-mm-dd", 10} ), Modeling Type( "Continuous" ) ),
Col("/gesmes:Envelope/Cube/Cube/Cube/@currency",
Column Name( "currency" ), Fill( "Use Once" ),
Type( "Character" ), Format( {"Best"} ), Modeling Type( "Nominal" ) ),
Col("/gesmes:Envelope/Cube/Cube/Cube/@rate",
Column Name( "rate" ), Fill( "Use Once" ),
Type( "Numeric" ), Format( {"Best"} ), Modeling Type( "Continuous" ) )
),
XML Wizard( 0 )
);