I stared at my code for a solid 5 mins trying to figure out what I screwed up (19:35) I created my own XML file, and by this point knew it was working just fine. Turns out...i did not capitalize the nodes in the XML file, but I did capitalize them in the code. It's amazing how "Name" is totally different from "name". No sarcasm, it's flexible.
@dmitriichashchin75664 жыл бұрын
I cant see ur XML file in the description...
@jrgomez Жыл бұрын
Very good explanation. Finally I understood how to deal with XML files.
@Aarabstrait4 жыл бұрын
You just saved me a day of work ! Keep up the good content ... +1 sub 👍
@NeuralNine4 жыл бұрын
glad to hear that appreciate it :)
@Enteriel3 жыл бұрын
BEST XML TUTORIAL FOR PYTHON THANK YOU !!!
@TejNarayanan3 жыл бұрын
Very well explained, thank you, can you please also suggest how to get the outputs as a separate dataframe/file (especially from the first method).
@ali-om4uv3 жыл бұрын
How are you supposed to know that these 3 functions are getting called in the original class? In your code it is not obvious that they are getting called at all.
@nitishasthana032 жыл бұрын
How to extract values from a tag that has multiple child. For example, if the had multiple tags with then it only gives the first element not the second one.
@federicobau86513 жыл бұрын
Nice work man
@wanderborn.3 жыл бұрын
Nicely explained the concept of how to approach an XML file. Thanks for all those details. I searched your videos and couldn't find anything else about how to use XML files for data analysis. I mean: get needed attributes, nodes and export them into data-frame or CSV file for a further convenient use. There are plenty of 'simple' samples of XML to CSV transformations online, but none with a real 'complex' structured XML with attributes in sub-child and such. Would it be possible for you to create such 'in demand' tutorial? BTW, bought your book '3 in 1' and hope to learn a lot on data science. Cheers,
@VishalSharma-rn7mt4 жыл бұрын
Thank you so much, great video. It helped me a lot.
@samp94182 жыл бұрын
This is a really good tutorial. Thank you so much!
@qaiszakry19753 жыл бұрын
Hi. In the dom section of your tutorial when you used getElementByTagName you used the index [0] for each of the name, age, weight and height. May I ask you to explain that? I thought since we have a for loop which can take care of getting first index. Please explain
@anilsiddabathula31584 жыл бұрын
Hi bro, Can yu tell how can i extract xml file in python to csv for data analysis
@oritsemisanomare19412 жыл бұрын
Thank you for this, it was actually easy to understand. But I replicated the last line where you wrote to the XML file, and it didn't work... help please.
@My1405NguyenThiThanh Жыл бұрын
Hi can you connect with database to create this xml ? I need do that for my task
@prateeksarangi91872 жыл бұрын
Thanks Mate
@gabriellopezmontesinos29514 жыл бұрын
Nice video dude!!!
@Captinofthemudslayer4 жыл бұрын
this example is a little too simple could you do one with a more complex site like yahoo finance? How would i go about parsing the table on it
@mstFPV5 жыл бұрын
Can you make a vid of the top 5 best things you can make in Python?
@NeuralNine5 жыл бұрын
I will make some project videos and project idea videos in the future but currently I am working on the data science playlist! :)
@PawanKumar-un7sk2 жыл бұрын
need that xml document could u please provide us
@lada2105apturbo3 жыл бұрын
very amazing! + 1 sub
@GFDNERFERSGAMING4 жыл бұрын
What if i wanted to count how many times each age pops up.
@edgarsan719914 жыл бұрын
Awesome video I am impress just one question how to pass all this info to a data base or a mean a SQlite database?,,, very nice code again
@NeuralNine4 жыл бұрын
Have you watched the tutorial about databases? :)
@edgarsan719914 жыл бұрын
@@NeuralNine Yes of course it's very good, but I have another question how do you read more than 1 xml file? I hear that have to use the glob function like a said I'm starting.
@NeuralNine4 жыл бұрын
@@edgarsan71991 what do you mean by reading two files? You mean at the same time?
@Rahul-ff1vx4 жыл бұрын
This data you opened is like an html file
@excellentgyankosh4 жыл бұрын
From which college you learned all that.
@NeuralNine4 жыл бұрын
I didn't learn Python in college at all. But I currently study at the Technical University of Vienna
@eliyaben9277 Жыл бұрын
lol he forgot about the link
@jasperzanjani3 жыл бұрын
how dare you use Notepad++ in a coding tutorial
@sanjaybhat42604 жыл бұрын
This is not a intermideate level. Its a beginner level. I mean come on the xml you chose is sooo simple. Choose the words of your title carefully. otherwise you might invite some dislikes like i am disliking your video right now.
@test555channel3 жыл бұрын
if you are a begginer with python you dont start with xml, you start with if,strings etc.
@pedropaes9023 жыл бұрын
I've done a few paid python courses, from beginner to intermediate, and none of them taught how to work with xml. The file he used might be simple, but the python code itself isn't
@letsbye3 жыл бұрын
whats ur problem man, its a free content, u can go some where else, if you think you are too good here..!!
@sanjaybhat42603 жыл бұрын
@@letsbye free content doesn't mean u can mislead with titles. U r so naive that I don't even feel u r worth me spending my energy to make u understand.
@letsbye3 жыл бұрын
@@sanjaybhat4260 cheers, keep going now..!!
@jsmyers24151 Жыл бұрын
For some reason, Python 3.10 is looking for a def __init__. I keep getting messages like this: Instance attribute current defined outside __init__:17 Instance attribute name defined outside __init__:24 Instance attribute age defined outside __init__:26 Instance attribute weight defined outside __init__:28 Instance attribute height defined outside __init__:30 Instance attribute current defined outside __init__:41 Of course, I understand that the number at the end of each line is the number of the line where the problem is being flagged, but I'm not understanding why Your code works and mine gives these error messages. And, that's not all of them. I'm also getting these error messages: C:\Users\jmyers\AppData\Local\Microsoft\WindowsApps\python3.10.exe "C:\Users\jmyers\PycharmProjects\Intermediate\XML Processing.py" Traceback (most recent call last): File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\xml\sax\expatreader.py", line 217, in feed self._parser.Parse(data, isFinal) xml.parsers.expat.ExpatError: no element found: line 48, column 0 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\jmyers\PycharmProjects\Intermediate\XML Processing.py", line 47, in parser.parse('data.xml') File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\xml\sax\expatreader.py", line 111, in parse xmlreader.IncrementalParser.parse(self, source) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\xml\sax\xmlreader.py", line 127, in parse self.close() File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\xml\sax\expatreader.py", line 240, in close self.feed(b"", isFinal=True) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\xml\sax\expatreader.py", line 221, in feed self._err_handler.fatalError(exc) File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.3056.0_x64__qbz5n2kfra8p0\lib\xml\sax\handler.py", line 38, in fatalError raise exception xml.sax._exceptions.SAXParseException: data.xml:48:0: no element found It's finding errors in lines of code that don't even exist in this program. What to do about that? But, yet, on top of all that (which is actually coming after these errors), I get the print out of the XML file. Weird!
@jsmyers24151 Жыл бұрын
Okay. Once again, I found my problem. In the XML file, I forgot to close the group with . Once I did that, all my troubles seemed so far away. Sorry, had a Beatles moment, there. All of the errors disappeared.
@cuneytozkurt486710 ай бұрын
hi, your video's so great. btw I'm trying to send to pandas but results are so bad as: 0 1 NaN NaN 1 NaN Jason Newsted NaN 2 NaN NaN Bass Guitar 3 NaN NaN NaN 4 100 NaN NaN I don't know how can I get these to same row... My wrong kod is like: thank you... class GroupHandler(xml.sax.ContentHandler): def startElement(self, name: str, attrs): self.current = name self.current_data = {} def endElement(self, name): if name == "gl-cor:accountMainID": self.data.append({"NO": self.currentText}) elif name == "gl-cor:accountMainDescription": self.data.append({"NAME":self.currentText}) elif name == "gl-cor:accountSubDescription": self.data.append({"ENSTRUMENT":self.currentText}) if name == "gl-cor:account": self.data.append(self.current_data) def characters(self, content): self.currentText = content.strip() def __init__(self): self.data = []