Ich arbeite gerade an einer Datenbank und möchte von XML zu einem Pandas DataFrame wechseln und bin schon lange nicht mehr da. Ich habe keine Ahnung, wie ich dieses Problem lösen kann.Python und Pandas: XML -> DataFrame
j=0
for rows in root.findall('row'):
i=0
for cells in root.findall('cell') in rows:
if i==0:
#Name of the country is on the 0-th tag "cell" of each "row"
country[j]=cells.text
elif i==17:
#Number of students is on the 17-th tag "cell" of each "row"
numberStudent[j]=cells.text
i=i+1
j=j+1
Data=pd.DataFrame({'country': [country], 'number of student': [numberStudent]})
Wenn ich versuche, Daten zu lesen, gibt es nur einen Datenrahmen mit einem Wert 0 für Land und 0 für numberStudent. Ich verstehe nicht, was falsch ist. Ich habe bereits auf diesem Forum nach Antwort gesucht, aber ich bin immer noch fest.
Auch ich bin mir nicht sicher, ob ich richtig mache. Ich möchte die 0-te ans 17-te Tag "Zelle" in jeder Eltern-Tag "Zeile" finden. Ist es richtig, zwei Mal "in" in einer Deklaration für die zweite zu verwenden?
Danke für Ihre Hilfe,
Cyril