473,408 Members | 1,767 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Reading 5MB xml with python

realin
254 100+
hiya all,

However, the title says it all but still i want to explain it further. I am trying to fetch a xml file which is lying at different size. The file size is like >5MB. So as soon as i write my code, the browser keeps on waiting for the response and in the end it freezes or displays time out.
What can be the work around for this ?
I am using google's app engine, so not exactly core python. And i would like to mention that i started learning python just half an hour back, i am a programmer of php, ruby on rails and little bit of java .. so its app engine is more like servlet has get/post methods..

Please help me with it, is it possible using threads ? spliting the file or what ?

Thanks & Regards
Realin !
Sep 10 '08 #1
5 1274
Laharl
849 Expert 512MB
Which XML API are you using, DOM or SAX? For large files (on the order of what you're dealing with), I believe SAX is the better choice.

You could use a thread to read through the file in the background, but it's going to be reasonably slow no matter what...
Sep 10 '08 #2
realin
254 100+
Which XML API are you using, DOM or SAX? For large files (on the order of what you're dealing with), I believe SAX is the better choice.

You could use a thread to read through the file in the background, but it's going to be reasonably slow no matter what...
hiya laharl,

thanks for the quick reply.. I am using DOM, i will give a try to SAX. Time is no constraint, so what do you suggest now ?

I am not a die hard fan of threads though, i want my code to be much more simpler, if you think SAX can do it without having to use thread, then i would be more than happy :)

waiting for ur reply
thanks :)
Sep 10 '08 #3
realin
254 100+
hiya all,

I m unable to get a code to fetch XML from a URL link using SAX.
Can anyone please help me in that .. its really urgent

please
Sep 10 '08 #4
Laharl
849 Expert 512MB
I've never actually used SAX (only xml.dom.minidom), but were I to guess, you'd use something from url or some other networking library to get the XML file from the server and then SAX to process it.
Sep 10 '08 #5
realin
254 100+
I've never actually used SAX (only xml.dom.minidom), but were I to guess, you'd use something from url or some other networking library to get the XML file from the server and then SAX to process it.
hiya

sorry for late update, was outta town actually. I had to use urllib for doing the same, but google app engine wont allow me to download some bulk size files, so i had to drop the idea of importing data thru XML.

However, i found a nice utility called bulkuploader using CSV files. I converted XMLs into CSV using php and then using bulkuploader utility, i just pushed the data in Datastore.

thanks for your help, its always good to see you guys coming up and helping :)

cheer!!
Sep 15 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Raymond Hettinger | last post by:
Found in a pamphlet at a pre-school: --------------------------------------- Reading improves vocabulary Reading raises cultural literacy through shared knowledge Reading develops writing skills...
4
by: Xah Lee | last post by:
# -*- coding: utf-8 -*- # Python # to open a file and write to file # do f=open('xfile.txt','w') # this creates a file "object" and name it f. # the second argument of open can be
0
by: travis ray | last post by:
Hi, I have an extension in which a file object is created in python and passed down to a c extension which attempts to read from it or write to it. Writing to the file pointer seems to work...
0
by: philip20060308 | last post by:
Hi all, Has anyone ever seen Python 2.4.1's httplib choke when reading chunked content? I'm using it via urrlib2, and I ran into a particular server that returns something that httplib doesn't...
1
by: Andrea Gavana | last post by:
Hello NG, that may sound a silly question, but I didn't find anything really clear about the issue of reading unformatted big endian files with Python. What I was doing till now, was using...
2
by: Jonathan Hunt | last post by:
Hi all, I have had a look on google/freshmeat etc. so please forgive me if I've missed an obvious answer. Can someone point me to a simple library to read/write ODF spreadsheets (i.e. ...
10
by: Tyler | last post by:
Hello All: After trying to find an open source alternative to Matlab (or IDL), I am currently getting acquainted with Python and, in particular SciPy, NumPy, and Matplotlib. While I await the...
42
by: psbasha | last post by:
Hi, Is it necessary in Python to close the File after reading or writing the data to file?.While refering to Python material ,I saw some where mentioning that no need to close the file.Correct me...
2
by: Benoit | last post by:
I got myself into programming late in the summer and have dabbled in python for the most part in that time, recently beginning work on a music player. In January, I start my minor in Information...
12
by: WaterWalk | last post by:
Hello. I wonder what's the effective way of figuring out how a piece of python code works. With C I often find it very useful to be able to run the code in step mode and set breakpoints in a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.