如何用python(或其他语言)将XML传递到Excel?

2024-09-24 22:26:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试将XML传递到excel表中以进行进一步分析(图形、动态表等)。我使用wget(linux)从HTTP服务器请求信息,然后将其传递到Windows,然后我想知道如何将这个XML文件传递到表中

这是用于从http服务器重新获取数据的24个XML文件(每小时1个)。每小时请求的部分解决了,但是数据处理是我的问题

所以XML文件是这样的:

<Ptexport version="1.6.0" >

<Response><RR cid="1459546492000" sid="38587" eod="0">

<RR1 direction="0" statTime="1556668838385" lostperc="0" dmax="264947" jmax="50154" />
<RR1 direction="1" statTime="1556668838385" lostperc="0" dmax="34530" jmax="16085" />
<RR1 direction="0" statTime="1556668898385" lostperc="28428" dmax="239192" jmax="21417" />
<RR1 direction="1" statTime="1556668898385" lostperc="0" dmax="40576" jmax="19246" />
<RR1 direction="0" statTime="1556668958386" lostperc="31666" dmax="257147" jmax="22487" />
<RR1 direction="1" statTime="1556668958386" lostperc="0" dmax="52772" jmax="9648" />
<RR1 direction="0" statTime="1556669018386" lostperc="36666" dmax="236172" jmax="28367" />
<RR1 direction="1" statTime="1556669018386" lostperc="0" dmax="75074" jmax="9524" />
<RR1 direction="0" statTime="1556669078385" lostperc="26711" dmax="210017" jmax="28195" />
<RR1 direction="1" statTime="1556669078385" lostperc="0" dmax="87410" jmax="11392" />
<RR1 direction="0" statTime="1556669138386" lostperc="16638" dmax="215571" jmax="23909" />
</RR>

<RR cid="1459546492000" sid="34123" eod="0">

<RR1 direction="0" statTime="1556668832391" lostperc="1000000" dmax="0" jmax="0" />
<RR1 direction="1" statTime="1556668832391" lostperc="0" dmax="0" jmax="0" />
<RR1 direction="0" statTime="1556668892391" lostperc="1000000" dmax="0" jmax="0" />
<RR1 direction="1" statTime="1556668892391" lostperc="0" dmax="0" jmax="0" />
<RR1 direction="0" statTime="1556668952391" lostperc="1000000" dmax="0" jmax="0" />
<RR1 direction="1" statTime="1556668952391" lostperc="0" dmax="0" jmax="0" />

</RR></Response></Ptexport>

因此,我们可以看到给定时间内有6个值的一个标记:

sid:是在每次测量开始时,我使用的节点id。 RR1方向:注册表是上游还是下游('1'或'0') stattime:epoch linux时间(我知道如何将它传递给人类时间,没有问题) lostperc,dmax,jmax:电信价值

因此,我希望在Excel中显示数据,如下所示:

Excel RESULT


Tags: 文件服务器linux时间rrxml小时sid