我有一个 .csv 文件,其中包含与比特币钱包(发送和接收的交易)相关的近 100 万笔交易的交易 ID,我将其作为数据表读入 R。现在我正在尝试在表格中添加另一列,其中列出了每笔交易的费用。这可以使用 API 调用来完成。
For example, to get the fee for the txid 73336c8b2f8bbf9c4165de515765463d6e835a9f3f87bf822d8bcb23c074ae7f, I have to open: https://blockchain.info/q/txfee/73336c8b2f8bbf9c4165de515765463d6e835a9f3f87bf822d8bcb23c074ae7f and read the data there directly.
我所做的:首先,我使用 Excel 编辑 .csv 文件,为每一行的 url 添加一个新列。然后在R中编写了以下代码:
for(i in 1:nrow(transactions))
transactions$fee[i] <- scan(transactions$url[i])
但这样它在 1 秒内只更新 2-3 行。由于我是新手,因此必须有更有效的方法来做同样的事情。