473,847 Members | 1,735 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

xml processing

I've like to use python to maintain a small addressbook which lives on a Sharp
Zaurus. This list will never grow beyond 200 or so entries. I've installed
pyxml.

Speaking generally, given a wxpython app to do data entry,
I'm planning to:

1. parse the addressbook file, loading its data into an array.
2. Perform any edit operations within the array.
3. Write out a finished xml file from the array when I'm done.

Is this reasonable? Better, smarter ways to accomplish this?

Thanks for any advice.

Jeff Elkins

Jul 19 '05 #1
4 1393
Jeff Elkins wrote:
I've like to use python to maintain a small addressbook which lives on a Sharp
Zaurus. This list will never grow beyond 200 or so entries. I've installed
pyxml.

Speaking generally, given a wxpython app to do data entry,
I'm planning to:

1. parse the addressbook file, loading its data into an array.
2. Perform any edit operations within the array.
3. Write out a finished xml file from the array when I'm done.

Is this reasonable? Better, smarter ways to accomplish this?


Why XML?

I guess the simplest solution whould be to use pickle.

Saving:
import pickle
l = []
l.append(('Alan ', '1st Street', 123456))
l.append(('Ben' , '2nd Street', 234567))
l.append(('Clar k', '3rd Street', 345678))
f = open('phonebook ','w')
pickle.dump(l, f)
f.close()
Loading: import pickle
f2 = open('phonebook ')
l = pickle.load(f2)
f2.close()
for item in l: print item
('Alan', '1st Street', 123456)
('Ben', '2nd Street', 234567)
('Clark', '3rd Street', 345678)

The file looks like this: print open('phonebook ').read() (lp0
(S'Alan'
p1
S'1st Street'
p2
I123456
tp3
a(S'Ben'
p4
S'2nd Street'
p5
I234567
tp6
a(S'Clark'
p7
S'3rd Street'
p8
I345678
tp9
a.


Ok, the file content might not seem completely obvious, but it's
not really so difficult to parse it, and it's certainly less verbose
than XML. Above all, much less code.

BTW, cPickle is faster than pickle, but I suspect it doesn't matter
with such a small amount of data. It's easy to replace "import pickle"
with "import cPickle as pickle" to try it out.
Jul 19 '05 #2
On Wednesday 01 June 2005 09:51 am, Magnus Lycka wrote:
Jeff Elkins wrote:
I've like to use python to maintain a small addressbook which lives on a
Sharp Zaurus. This list will never grow beyond 200 or so entries. I've
installed pyxml.

Speaking generally, given a wxpython app to do data entry,
I'm planning to:

1. parse the addressbook file, loading its data into an array.
2. Perform any edit operations within the array.
3. Write out a finished xml file from the array when I'm done.

Is this reasonable? Better, smarter ways to accomplish this?


Why XML?

I guess the simplest solution whould be to use pickle.


The Zaurus addressbook app depends on an xml datafile, so I'm stuck with that
format. I just want to to maintenence and data entry on the PC for ease of
use vs typing on the Zaurus' tiny keyboard. I could just edit the raw xml
file, then copy it to the Zaurus, but I'd like to have something a little
spiffier...

Jeff
Jul 19 '05 #3
Jeff Elkins wrote:
I've like to use python to maintain a small addressbook which lives on a Sharp
Zaurus. This list will never grow beyond 200 or so entries. I've installed
pyxml.
If you're not committed to pyxml, you might consider using ElementTree:

http://effbot.org/zone/element-index.htm

I find it *way* easier to work with.

Speaking generally, given a wxpython app to do data entry,
I'm planning to:

1. parse the addressbook file, loading its data into an array.
2. Perform any edit operations within the array.
3. Write out a finished xml file from the array when I'm done.

Is this reasonable? Better, smarter ways to accomplish this?


Seems pretty reasonable. Another option might be to parse the
addressbook file into an XML object and then modify the XML object
itself. E.g.:

tree = ElementTree(fil e="...")
elem = tree.getroot()
for node in elem.findall(". .."):
node.text = "..."

STeVe
Jul 19 '05 #4
On Wednesday 01 June 2005 11:01 am, Steven Bethard wrote:
If you're not committed to pyxml, you might consider using ElementTree:

http://effbot.org/zone/element-index.htm

I find it *way* easier to work with.


Thanks. I've installed it and am experimenting.
Jul 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3418
by: Newbie | last post by:
I am doing some robotics projects but my main area of interest is trying out several algorithms for the processing of the stream of data coming from the video. I am wondering what type of camera I should invest in. Either I could buy a web cam and hope I can find a driver I could either modify or use. i.e. every frame is somehow stored on the computer automagically or I could buy a camera not unlike the AVRcam...
4
8113
by: gl | last post by:
I have just started a project that's going to do very heavy credit card processing through asp.net and i had some questions. I've never really done any cc processing through code and I wasn't sure where to get started. Can anyone suggest a particular gateway or cc processor? I saw a component called ..net charge that seems really promising, has anyone used it? Have any of you done a full e-commerce site and have some suggestions? What is...
0
1989
by: Ganapathy | last post by:
I have COM dll code written in VC 6.0. When i tried compiling this code in VC 7, The MIDL cmpiler gets called twice. i.e. it initially compiles fully & immediately a line - 64 bit processing' comes, followed by the 64 bit compilation of the IDl file. The comlpilation goes thro' the full stage and then the StdAfx.cpp is compiled. I have another similar VC 6 COM dll code that gets compiled without invoking the 64 bit processing of the...
2
1504
by: Luiz Vianna | last post by:
Hi folks, I got a problem that certainly someone had too. After a user request, I (my server) must process a lot of data that will expend some time. During this process I must inform the user the status of the overall process. What I'm facing is that my ASPX/vb file that does this long task is completely processed before some response could be given to the user. Result: After filling the form, the user clicks the button and the form...
6
5008
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing for long running reports. When the processing is complete it uses crystal reports to load a template file, populate it, and then export it to a PDF. It works fine so far....
2
2031
by: domtam | last post by:
Hi all, Here is what I want: when a user clicks a <asp:button>, its event handler will do some server-side processing and then pop up a windows of another page. As far as I know, if no pop-up blocker is disabled, the button event handler can be something like the following to pop-up a window after server-side processing
4
1586
by: Fao, Sean | last post by:
I'm trying to show an animated image temporarily while the web server is processing a long request. I attempted to use a combination of CSS styles and JavaScript to temporarily hide or show only appropriate portions of the page (e.g. hide the data and show an animated "processing" image while the server is doing work), however, it's not exactly working out the way I had hoped. What's the best way to accomplish this task? Thank you in...
10
5758
by: Enrique Cruiz | last post by:
Hello all, I am currently implementing a fairly simple algorithm. It scans a grayscale image, and computes a pixel's new value as a function of its original value. Two passes are made, first horizontally and second vertically. The problem I have is that the vertical pass is 3 to 4 times slower than the horizontal, although the code is _exactly_ the same in both cases?! The code itself is very simple. There are 2 loops to scan through...
0
17546
ADezii
by: ADezii | last post by:
In the Tip of the Week #19, we demonstrated Transaction Processing, specifically as it applies to DAO (Data Access Objects). In this week's Tip, we'll illustrate how Transaction Processing can be used within the context of ADO (ActiveX Data Objects). Please refer to the Link below if you wish to see an Overview of Transaction Processing, how it is implemented within DAO, or special issues to be aware of when utilizing Transaction Processing in...
0
2041
by: tavares | last post by:
(Our apologies for cross-posting. We appreciate if you kindly distribute this information by your co- workers and colleagues.) *************************************************************************** Symposium “Image Processing and Data Visualization” 2nd South-East European Conference on Computational Mechanics (SEECCM 2009) Island of Rhodes, Greece, 22-24 June 2009
0
9882
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9727
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10645
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10706
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9481
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7880
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4524
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4116
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3160
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.