XML to Datafreme
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
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
add a comment |
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
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
add a comment |
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
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
python xml pandas dataframe
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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
that was a piece jf xml , the original document sec.gov/Archives/edgar/data/1067983/000095012318011885/…
– IgBell
Nov 24 '18 at 19:47
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
that was a piece jf xml , the original document sec.gov/Archives/edgar/data/1067983/000095012318011885/…
– IgBell
Nov 24 '18 at 19:47
add a comment |
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
that was a piece jf xml , the original document sec.gov/Archives/edgar/data/1067983/000095012318011885/…
– IgBell
Nov 24 '18 at 19:47
add a comment |
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
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
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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