Python Intermediate Tutorial #10 - XML Processing

  Рет қаралды 36,977

NeuralNine

NeuralNine

Күн бұрын

Пікірлер: 47
@Dr.Cosmar
@Dr.Cosmar 2 жыл бұрын
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.
@dmitriichashchin7566
@dmitriichashchin7566 4 жыл бұрын
I cant see ur XML file in the description...
@jrgomez
@jrgomez Жыл бұрын
Very good explanation. Finally I understood how to deal with XML files.
@Aarabstrait
@Aarabstrait 4 жыл бұрын
You just saved me a day of work ! Keep up the good content ... +1 sub 👍
@NeuralNine
@NeuralNine 4 жыл бұрын
glad to hear that appreciate it :)
@Enteriel
@Enteriel 3 жыл бұрын
BEST XML TUTORIAL FOR PYTHON THANK YOU !!!
@TejNarayanan
@TejNarayanan 3 жыл бұрын
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-om4uv
@ali-om4uv 3 жыл бұрын
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.
@nitishasthana03
@nitishasthana03 2 жыл бұрын
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.
@federicobau8651
@federicobau8651 3 жыл бұрын
Nice work man
@wanderborn.
@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-rn7mt
@VishalSharma-rn7mt 4 жыл бұрын
Thank you so much, great video. It helped me a lot.
@samp9418
@samp9418 2 жыл бұрын
This is a really good tutorial. Thank you so much!
@qaiszakry1975
@qaiszakry1975 3 жыл бұрын
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
@anilsiddabathula3158
@anilsiddabathula3158 4 жыл бұрын
Hi bro, Can yu tell how can i extract xml file in python to csv for data analysis
@oritsemisanomare1941
@oritsemisanomare1941 2 жыл бұрын
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
@My1405NguyenThiThanh Жыл бұрын
Hi can you connect with database to create this xml ? I need do that for my task
@prateeksarangi9187
@prateeksarangi9187 2 жыл бұрын
Thanks Mate
@gabriellopezmontesinos2951
@gabriellopezmontesinos2951 4 жыл бұрын
Nice video dude!!!
@Captinofthemudslayer
@Captinofthemudslayer 4 жыл бұрын
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
@mstFPV
@mstFPV 5 жыл бұрын
Can you make a vid of the top 5 best things you can make in Python?
@NeuralNine
@NeuralNine 5 жыл бұрын
I will make some project videos and project idea videos in the future but currently I am working on the data science playlist! :)
@PawanKumar-un7sk
@PawanKumar-un7sk 2 жыл бұрын
need that xml document could u please provide us
@lada2105apturbo
@lada2105apturbo 3 жыл бұрын
very amazing! + 1 sub
@GFDNERFERSGAMING
@GFDNERFERSGAMING 4 жыл бұрын
What if i wanted to count how many times each age pops up.
@edgarsan71991
@edgarsan71991 4 жыл бұрын
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
@NeuralNine
@NeuralNine 4 жыл бұрын
Have you watched the tutorial about databases? :)
@edgarsan71991
@edgarsan71991 4 жыл бұрын
@@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.
@NeuralNine
@NeuralNine 4 жыл бұрын
@@edgarsan71991 what do you mean by reading two files? You mean at the same time?
@Rahul-ff1vx
@Rahul-ff1vx 4 жыл бұрын
This data you opened is like an html file
@excellentgyankosh
@excellentgyankosh 4 жыл бұрын
From which college you learned all that.
@NeuralNine
@NeuralNine 4 жыл бұрын
I didn't learn Python in college at all. But I currently study at the Technical University of Vienna
@eliyaben9277
@eliyaben9277 Жыл бұрын
lol he forgot about the link
@jasperzanjani
@jasperzanjani 3 жыл бұрын
how dare you use Notepad++ in a coding tutorial
@sanjaybhat4260
@sanjaybhat4260 4 жыл бұрын
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.
@test555channel
@test555channel 3 жыл бұрын
if you are a begginer with python you dont start with xml, you start with if,strings etc.
@pedropaes902
@pedropaes902 3 жыл бұрын
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
@letsbye
@letsbye 3 жыл бұрын
whats ur problem man, its a free content, u can go some where else, if you think you are too good here..!!
@sanjaybhat4260
@sanjaybhat4260 3 жыл бұрын
@@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.
@letsbye
@letsbye 3 жыл бұрын
@@sanjaybhat4260 cheers, keep going now..!!
@jsmyers24151
@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
@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.
@cuneytozkurt4867
@cuneytozkurt4867 10 ай бұрын
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 = []
Python Intermediate Tutorial #11 - Logging
15:50
NeuralNine
Рет қаралды 12 М.
A Deep Dive Into Pathlib And The Magic Behind It
16:56
ArjanCodes
Рет қаралды 48 М.
One day.. 🙌
00:33
Celine Dept
Рет қаралды 48 МЛН
Do you love Blackpink?🖤🩷
00:23
Karina
Рет қаралды 22 МЛН
Full XML Processing Guide in Python
17:34
NeuralNine
Рет қаралды 81 М.
15 Python Libraries You Should Know About
14:54
ArjanCodes
Рет қаралды 403 М.
Python Data Classes Are AMAZING! Here's Why
16:11
Tech With Tim
Рет қаралды 85 М.
Java Online Training | Parsing XML using Java DOM Parser
14:10
Firebox Training
Рет қаралды 220 М.
XML & ElementTree  ||  Python Tutorial  ||  Learn Python Programming
10:30
5 Tips For Object-Oriented Programming Done Well - In Python
16:08
Python dataclasses will save you HOURS, also featuring attrs
8:50
Why is Python 150X slower than C?
10:45
Mehul - Codedamn
Рет қаралды 26 М.