XML to Datafreme





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















My code doesn't put values in Datafeame - all None, please help find mistake. Originaly I took code fron=m here
http://gokhanatil.com/2017/11/python-for-data-science-importing-xml-to-pandas-dataframe.html#comment-414932



my piece of xml



    xmlns="http://www.sec.gov/edgar/document   /thirteenf/informationtable"        xmlns:xsi="http://www.w3.org/2001/XMLSchema-   instance">
<infoTable>
<nameOfIssuer>AMERICAN AIRLS GROUP INC</nameOfIssuer>
<titleOfClass>COM</titleOfClass>
<cusip>02376R102</cusip>
<value>857267</value>
<shrsOrPrnAmt>
<sshPrnamt>20742000</sshPrnamt>
<sshPrnamtType>SH</sshPrnamtType>
</shrsOrPrnAmt>
<investmentDiscretion>DFND</investmentDiscretion>
<otherManager>4</otherManager>
<votingAuthority>
<Sole>20742000</Sole>
<Shared>0</Shared>
<None>0</None>
</votingAuthority>




my code



 import xml.etree.cElementTree as et
import pandas as pd


def getvalueofnode(node):
""" return node text or None """
return node.text if node is not None else None


def main():
""" main """
parsed_xml = et.parse("form13fInfoTable.xml")
dfcols = ['infoTable/nameOfIssuer', 'infotanle/cusip', 'infotable/value']
df_xml = pd.DataFrame(columns=dfcols)

for node in parsed_xml.getroot():
print(parsed_xml.getroot())
parsed_xml.getroot()

nameOfIssuer = node.find('informationTable/infoTable/nameOfIssuer')
cusip = node.find('infoTable/cusip')
value = node.find('infoTable/value')


df_xml = df_xml.append(pd.Series([getvalueofnode(nameOfIssuer),getvalueofnode(cusip), getvalueofnode(value)], index=dfcols),ignore_index=True)

print(df_xml)


main()









share|improve this question

























  • Possible duplicate of How to convert an XML file to nice pandas dataframe?

    – 576i
    Nov 24 '18 at 13:37











  • Look at stackoverflow.com/questions/28259301/… which should help.

    – 576i
    Nov 24 '18 at 13:38


















0















My code doesn't put values in Datafeame - all None, please help find mistake. Originaly I took code fron=m here
http://gokhanatil.com/2017/11/python-for-data-science-importing-xml-to-pandas-dataframe.html#comment-414932



my piece of xml



    xmlns="http://www.sec.gov/edgar/document   /thirteenf/informationtable"        xmlns:xsi="http://www.w3.org/2001/XMLSchema-   instance">
<infoTable>
<nameOfIssuer>AMERICAN AIRLS GROUP INC</nameOfIssuer>
<titleOfClass>COM</titleOfClass>
<cusip>02376R102</cusip>
<value>857267</value>
<shrsOrPrnAmt>
<sshPrnamt>20742000</sshPrnamt>
<sshPrnamtType>SH</sshPrnamtType>
</shrsOrPrnAmt>
<investmentDiscretion>DFND</investmentDiscretion>
<otherManager>4</otherManager>
<votingAuthority>
<Sole>20742000</Sole>
<Shared>0</Shared>
<None>0</None>
</votingAuthority>




my code



 import xml.etree.cElementTree as et
import pandas as pd


def getvalueofnode(node):
""" return node text or None """
return node.text if node is not None else None


def main():
""" main """
parsed_xml = et.parse("form13fInfoTable.xml")
dfcols = ['infoTable/nameOfIssuer', 'infotanle/cusip', 'infotable/value']
df_xml = pd.DataFrame(columns=dfcols)

for node in parsed_xml.getroot():
print(parsed_xml.getroot())
parsed_xml.getroot()

nameOfIssuer = node.find('informationTable/infoTable/nameOfIssuer')
cusip = node.find('infoTable/cusip')
value = node.find('infoTable/value')


df_xml = df_xml.append(pd.Series([getvalueofnode(nameOfIssuer),getvalueofnode(cusip), getvalueofnode(value)], index=dfcols),ignore_index=True)

print(df_xml)


main()









share|improve this question

























  • Possible duplicate of How to convert an XML file to nice pandas dataframe?

    – 576i
    Nov 24 '18 at 13:37











  • Look at stackoverflow.com/questions/28259301/… which should help.

    – 576i
    Nov 24 '18 at 13:38














0












0








0








My code doesn't put values in Datafeame - all None, please help find mistake. Originaly I took code fron=m here
http://gokhanatil.com/2017/11/python-for-data-science-importing-xml-to-pandas-dataframe.html#comment-414932



my piece of xml



    xmlns="http://www.sec.gov/edgar/document   /thirteenf/informationtable"        xmlns:xsi="http://www.w3.org/2001/XMLSchema-   instance">
<infoTable>
<nameOfIssuer>AMERICAN AIRLS GROUP INC</nameOfIssuer>
<titleOfClass>COM</titleOfClass>
<cusip>02376R102</cusip>
<value>857267</value>
<shrsOrPrnAmt>
<sshPrnamt>20742000</sshPrnamt>
<sshPrnamtType>SH</sshPrnamtType>
</shrsOrPrnAmt>
<investmentDiscretion>DFND</investmentDiscretion>
<otherManager>4</otherManager>
<votingAuthority>
<Sole>20742000</Sole>
<Shared>0</Shared>
<None>0</None>
</votingAuthority>




my code



 import xml.etree.cElementTree as et
import pandas as pd


def getvalueofnode(node):
""" return node text or None """
return node.text if node is not None else None


def main():
""" main """
parsed_xml = et.parse("form13fInfoTable.xml")
dfcols = ['infoTable/nameOfIssuer', 'infotanle/cusip', 'infotable/value']
df_xml = pd.DataFrame(columns=dfcols)

for node in parsed_xml.getroot():
print(parsed_xml.getroot())
parsed_xml.getroot()

nameOfIssuer = node.find('informationTable/infoTable/nameOfIssuer')
cusip = node.find('infoTable/cusip')
value = node.find('infoTable/value')


df_xml = df_xml.append(pd.Series([getvalueofnode(nameOfIssuer),getvalueofnode(cusip), getvalueofnode(value)], index=dfcols),ignore_index=True)

print(df_xml)


main()









share|improve this question
















My code doesn't put values in Datafeame - all None, please help find mistake. Originaly I took code fron=m here
http://gokhanatil.com/2017/11/python-for-data-science-importing-xml-to-pandas-dataframe.html#comment-414932



my piece of xml



    xmlns="http://www.sec.gov/edgar/document   /thirteenf/informationtable"        xmlns:xsi="http://www.w3.org/2001/XMLSchema-   instance">
<infoTable>
<nameOfIssuer>AMERICAN AIRLS GROUP INC</nameOfIssuer>
<titleOfClass>COM</titleOfClass>
<cusip>02376R102</cusip>
<value>857267</value>
<shrsOrPrnAmt>
<sshPrnamt>20742000</sshPrnamt>
<sshPrnamtType>SH</sshPrnamtType>
</shrsOrPrnAmt>
<investmentDiscretion>DFND</investmentDiscretion>
<otherManager>4</otherManager>
<votingAuthority>
<Sole>20742000</Sole>
<Shared>0</Shared>
<None>0</None>
</votingAuthority>




my code



 import xml.etree.cElementTree as et
import pandas as pd


def getvalueofnode(node):
""" return node text or None """
return node.text if node is not None else None


def main():
""" main """
parsed_xml = et.parse("form13fInfoTable.xml")
dfcols = ['infoTable/nameOfIssuer', 'infotanle/cusip', 'infotable/value']
df_xml = pd.DataFrame(columns=dfcols)

for node in parsed_xml.getroot():
print(parsed_xml.getroot())
parsed_xml.getroot()

nameOfIssuer = node.find('informationTable/infoTable/nameOfIssuer')
cusip = node.find('infoTable/cusip')
value = node.find('infoTable/value')


df_xml = df_xml.append(pd.Series([getvalueofnode(nameOfIssuer),getvalueofnode(cusip), getvalueofnode(value)], index=dfcols),ignore_index=True)

print(df_xml)


main()






python xml pandas dataframe






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 24 '18 at 12:12







IgBell

















asked Nov 24 '18 at 10:03









IgBellIgBell

11




11













  • Possible duplicate of How to convert an XML file to nice pandas dataframe?

    – 576i
    Nov 24 '18 at 13:37











  • Look at stackoverflow.com/questions/28259301/… which should help.

    – 576i
    Nov 24 '18 at 13:38



















  • Possible duplicate of How to convert an XML file to nice pandas dataframe?

    – 576i
    Nov 24 '18 at 13:37











  • Look at stackoverflow.com/questions/28259301/… which should help.

    – 576i
    Nov 24 '18 at 13:38

















Possible duplicate of How to convert an XML file to nice pandas dataframe?

– 576i
Nov 24 '18 at 13:37





Possible duplicate of How to convert an XML file to nice pandas dataframe?

– 576i
Nov 24 '18 at 13:37













Look at stackoverflow.com/questions/28259301/… which should help.

– 576i
Nov 24 '18 at 13:38





Look at stackoverflow.com/questions/28259301/… which should help.

– 576i
Nov 24 '18 at 13:38












1 Answer
1






active

oldest

votes


















0














I'd write a comment, but I can't do that yet.



Is your xml file correct? It seems that you lack opening tag in your xml, one by the namespaces:



<root xmlns=... > your xml </root>


Also, the <infoTable> tag isn't closed






share|improve this answer
























  • that was a piece jf xml , the original document sec.gov/Archives/edgar/data/1067983/000095012318011885/…

    – IgBell
    Nov 24 '18 at 19:47














Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53457071%2fxml-to-datafreme%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














I'd write a comment, but I can't do that yet.



Is your xml file correct? It seems that you lack opening tag in your xml, one by the namespaces:



<root xmlns=... > your xml </root>


Also, the <infoTable> tag isn't closed






share|improve this answer
























  • that was a piece jf xml , the original document sec.gov/Archives/edgar/data/1067983/000095012318011885/…

    – IgBell
    Nov 24 '18 at 19:47


















0














I'd write a comment, but I can't do that yet.



Is your xml file correct? It seems that you lack opening tag in your xml, one by the namespaces:



<root xmlns=... > your xml </root>


Also, the <infoTable> tag isn't closed






share|improve this answer
























  • that was a piece jf xml , the original document sec.gov/Archives/edgar/data/1067983/000095012318011885/…

    – IgBell
    Nov 24 '18 at 19:47
















0












0








0







I'd write a comment, but I can't do that yet.



Is your xml file correct? It seems that you lack opening tag in your xml, one by the namespaces:



<root xmlns=... > your xml </root>


Also, the <infoTable> tag isn't closed






share|improve this answer













I'd write a comment, but I can't do that yet.



Is your xml file correct? It seems that you lack opening tag in your xml, one by the namespaces:



<root xmlns=... > your xml </root>


Also, the <infoTable> tag isn't closed







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 24 '18 at 13:44









AdrianAdrian

9026




9026













  • that was a piece jf xml , the original document sec.gov/Archives/edgar/data/1067983/000095012318011885/…

    – IgBell
    Nov 24 '18 at 19:47





















  • that was a piece jf xml , the original document sec.gov/Archives/edgar/data/1067983/000095012318011885/…

    – IgBell
    Nov 24 '18 at 19:47



















that was a piece jf xml , the original document sec.gov/Archives/edgar/data/1067983/000095012318011885/…

– IgBell
Nov 24 '18 at 19:47







that was a piece jf xml , the original document sec.gov/Archives/edgar/data/1067983/000095012318011885/…

– IgBell
Nov 24 '18 at 19:47






















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53457071%2fxml-to-datafreme%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Xamarin.form Move up view when keyboard appear

Post-Redirect-Get with Spring WebFlux and Thymeleaf

Anylogic : not able to use stopDelay()