将数据写入 CSV 文件

时间:2021-07-29 12:15:53

标签: shell scripting csv xml

我每天都会生成一个文件,其中包含许多网络服务请求和响应,我想将请求和响应的内容写入 CSV 文件。

以下格式的内容(请求和响应的内容一起)

phonenumber,RefID,DateTime,SOATransactionID,phonenumber,RefID

请注意,只有 Phonenumber,RefID,DateTime 要在 Input Request 中提取,SOATransactionID,phonenumber,RefID 要在 Output response 中提取。

样品请求和响应

#######################Input Request#######################
</soapenv:Header><soapenv:Body>
        <cre:Customer>
            <cre:account>
                <cor:phonenumber>7654899089</cor:phonenumber>
            </cre:account>
            <cre:RefID>ABC1234</cre:RefID>
            <cre:DateTime>2002-04-20T00:00:06.774+01:00</cre:DateTime>
        </cre:Customer>
    </soapenv:Body></soapenv:Envelope>
#######################Output Response#######################
<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cor="http://reftest.com/coredata1"><soapenv:Header><cor:SOATransactionID>123-456-890</cor:SOATransactionID></soapenv:Header><soapenv:Body><ns3:Response xmlns:ns3="http://reftest.com/Testdata1"><ns3:successResponse><ns3:account><cor:phonenumber>7654899089</cor:phonenumber></ns3:account><ns3:RefID>ABC1234</ns3:RefID></ns3:successResponse></ns3:Response></soapenv:Body></soapenv:Envelope>
#######################Input Request#######################
</soapenv:Header><soapenv:Body>
        <cre:Customer>
            <cre:account>
                <cor:phonenumber>8766769089</cor:phonenumber>
            </cre:account>
            <cre:RefID>ABC1234</cre:RefID>
            <cre:DateTime>2002-04-20T00:00:06.774+01:00</cre:DateTime>
        </cre:Customer>
    </soapenv:Body></soapenv:Envelope>
#######################Output Response#######################
<?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cor="http://reftest.com/coredata1"><soapenv:Header><cor:SOATransactionID>123-456-890</cor:SOATransactionID></soapenv:Header><soapenv:Body><ns3:Response xmlns:ns3="http://reftest.com/Testdata1"><ns3:successResponse><ns3:account><cor:phonenumber>8766769089</cor:phonenumber></ns3:account><ns3:RefID>ABC1234</ns3:RefID></ns3:successResponse></ns3:Response></soapenv:Body></soapenv:Envelope>

谢谢

0 个答案:

没有答案