python - How to mport a file with extension .A?
问题描述
I downloaded a file with extension .A which contains a time series I would like to work on in Python. I'm not an expert at all with .A files, but if I open it with a notepad I see it contains the data I'd like to work on. How can I conver that file in Python in order to work on it (i.e. an array, a pandas series...)?
import requests
response = requests.get("https://sdw-wsrest.ecb.europa.eu/service/data/EXR/D.USD.EUR.SP00.A?startPeriod=2021-02-20&endPeriod=2021-02-25")
data = response.text
解决方案
You need to read up on parsing XML. This code will get the data into a data structure typical for XML. You may mangle it as you see fit from there. You need to provide more information about how you'd like these data to look in order to get a more complete answer.
import requests
import xml.etree.ElementTree as ET
response = requests.get("https://sdw-wsrest.ecb.europa.eu/service/data/EXR/D.USD.EUR.SP00.A?startPeriod=2021-02-20&endPeriod=2021-02-25")
data = response.text
root = ET.fromstring(data)
推荐阅读
- python - 将单例矩阵的熊猫数据帧转换为数字数据帧
- c# - DataGrid - 添加不属于数据的行(用于“目录导航”)
- genexus - 如何在 Genexus 中解决这个 GXTest?
- mysql - 我使用node.js创建了一个rest api,在.get方法中我想取回一个json数组
- reactjs - 检查是否使用反应钩子卸载了组件?
- python - 从图像中提取矩形文本框
- python - 是否可以在运行时在 python 中检查 chromedriver.exe 版本?
- java - 写入 CSV 文件,无法写入第一行
- javascript - 如何管理使用 AWS Amplify 身份验证创建的用户
- python - MATLAB 的 lowpass() 函数在 python 中的等效函数?