这篇文章与 Linux 无关;它是关于使用JMP 下载货币换算数据。
Linux 计算器上的货币按钮最近引起了我的注意。
Calculator showing the currency conversion buttons显示货币换算按钮的计算器
他们如何获得最新的转换系数? 谷歌带我这里, 这让我这里, 这把我带到了这个欧洲中央银行页面包含费率以及指向 PDF、CSV 和 XML 下载的链接。 单击 XML 链接,您的浏览器可能会打开如下内容:
screenshot of FireFox showing an XML file of exchange rates显示汇率 XML 文件的 FireFox 屏幕截图
快速浏览一下就会发现这些汇率都是基于欧元的,因为欧元没有出现并且表格中没有 1.0000 因素。 这也是参考页面所说的:
based on the euro基于欧元
让我们将 XML 加载到数据表中。 JMP 15 的 XML 向导可以帮助构建 JSL 来执行此操作。 首先,将 XML 从浏览器保存到您的机器,然后使用文件 -> 打开,选择 XML 扩展名,选择您的文件,然后在向导中打开它。
Choose the XML extension to see the downloaded file选择 XML 扩展名以查看下载的文件
XML 向导打开,是时候决定感兴趣的列和行了。 打开统计列以查看重复数据在哪些键下并关闭名称列以使显示更适合屏幕:
opening the XML file with the wizard使用向导打开 XML 文件
你也可以使用 Tall Guess 来得到同样的东西。 Tall Guess 注意到 32 个重复条目并选择该键来生成行,然后选择所有(两个)子键来生成列。 它使用 Sampler 数据来确定子键是否应该生成数字或字符数据。
现在通过关闭 Stat Cols 并重新打开 Name Cols 来重命名列。 还要修饰其他一些东西,将货币的建模类型设置为名义型。 时间,姓名,主题在图片后描述...
Changing column names, adding some meta data更改列名,添加一些元数据
元数据还有其他三列:时间、姓名、主题。 时间似乎最有用;让我们保持每一行的时间。 名称和主题只能作为表变量保存;他们会在确定后出现:
The 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 )
);