473,769 Members | 2,085 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

List of objects X Database

I am writing a script that has to read data from an ASCII file of
about 50 Mb and do a lot of searches and calculations with that data.
That would be a classic problem solved by the use of a database
(SQLite would suit just fine), but that would require the user to
install more packages other than python itself, and that I am trying
to avoid.
Since the data is not too large, I wonder if there is another way to
store all data in memory and work with it more or less like a
database, doing searches and working with datafields.

This is not clear to me how can be implemented. I thought of creating
a class with the data structure, and creating a list of objects of
that class, each one containing one line of data from the "database".

Any thoughts or suggestions?

Thanks!
Eduardo

Oct 3 '07 #1
5 1208

On Oct 3, 2007, at 1:01 PM, MindMaster32 wrote:
I am writing a script that has to read data from an ASCII file of
about 50 Mb and do a lot of searches and calculations with that data.
That would be a classic problem solved by the use of a database
(SQLite would suit just fine), but that would require the user to
install more packages other than python itself, and that I am trying
to avoid.
Since the data is not too large, I wonder if there is another way to
store all data in memory and work with it more or less like a
database, doing searches and working with datafields.

This is not clear to me how can be implemented. I thought of creating
a class with the data structure, and creating a list of objects of
that class, each one containing one line of data from the "database".

Any thoughts or suggestions?
Berkeley DB?
Oct 3 '07 #2
Michael Bentley wrote:
>
On Oct 3, 2007, at 1:01 PM, MindMaster32 wrote:
>I am writing a script that has to read data from an ASCII file of
about 50 Mb and do a lot of searches and calculations with that data.
That would be a classic problem solved by the use of a database
(SQLite would suit just fine), but that would require the user to
install more packages other than python itself, and that I am trying
to avoid.
No it would not:
<URL:http://docs.python.org/lib/module-sqlite3.html>
(Well, its new in Python 2.5, but you didn't say you were restricted to
some older version.)

/W
Oct 3 '07 #3
On 3 oct, 22:01, MindMaster32 <egerm...@gmail .comwrote:

Hi,

Maybe PyDbLite (http://quentel.pierre.free.fr/PyDbLite/index.html) is
what you need : a single Python module, compatible with Python 2.3+,
that lets you manipulate data in memory

You can manage a database like this :

import PyDbLite
db = PyDbLite.Base(" dummy")
db.create("reco rd,"artist","re leased") # fields are untyped
db.insert("Clos er","Joy Division",1980)
db.insert("Diff erent Class","Pulp",1 996)
db.commit() # save to disk
print [ r for r in db if r["released"] 1990 ]
print db(artist="Joy Division")

Regards,
Pierre

Oct 3 '07 #4
MindMaster32 wrote:
I am writing a script that has to read data from an ASCII file of
about 50 Mb and do a lot of searches and calculations with that data.
That would be a classic problem solved by the use of a database
(SQLite would suit just fine), but that would require the user to
install more packages other than python itself, and that I am trying
to avoid.

Since the data is not too large, I wonder if there is another way to
store all data in memory and work with it more or less like a
database, doing searches and working with datafields.

This is not clear to me how can be implemented. I thought of creating
a class with the data structure, and creating a list of objects of
that class, each one containing one line of data from the "database".

Any thoughts or suggestions?
Python 2.5 ships with SQLite and also supports in-memory
storage of the data.

--
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source (#1, Oct 04 2007)
>>Python/Zope Consulting and Support ... http://www.egenix.com/
mxODBC.Zope.D atabase.Adapter ... http://zope.egenix.com/
mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
_______________ _______________ _______________ _______________ ____________

:::: Try mxODBC.Zope.DA for Windows,Linux,S olaris,MacOSX for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
Oct 4 '07 #5
MindMaster32 wrote:
>I am writing a script that has to read data from an ASCII file of
about 50 Mb and do a lot of searches and calculations with that data.
That would be a classic problem solved by the use of a database
(SQLite would suit just fine), but that would require the user to
install more packages other than python itself, and that I am trying
to avoid.
Since the data is not too large, I wonder if there is another way to
store all data in memory and work with it more or less like a
database, doing searches and working with datafields.

This is not clear to me how can be implemented. I thought of creating
a class with the data structure, and creating a list of objects of
that class, each one containing one line of data from the "database".

Any thoughts or suggestions?

Thanks!
Eduardo
What about shelve? It Requires some db support, yes....And what about
just reading the file and making a dict? It is a `csv' like file, so you
can just read it and generate a dict?

Cheers.
Gerardo
Oct 4 '07 #6

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

Similar topics

10
15138
by: Der Andere | last post by:
I need to implement a sorted (ordered) list. STL has no sorted list type as far as I know. Is there a (straight) way to implement a sorted list using STL? BTW: The type of items in the list will be a class. Is it necessary to implement the > or < operators or to write a compare-function that returns the larger or smaller of two classes? Ideally, the list begins with the smallest element. Cheers, Matthias
3
1987
by: kyle.tk | last post by:
So I have a central list of python objects that I want to be able to share between different process that are possibly on different computers on the network. Some of the processes will add objects to list and another process will be a GUI that will view objects in the list. I want this all to happen in real-time (e.g once a processes adds an object to the list the GUI will see it.) What would be the best way to accomplish this. Some of...
1
1787
by: zeke | last post by:
I have an Access database that suddenly opens without the list of objects (You know, Tables, Queries, Forms, Reports . .) at the left of the screen. The objects still exist - for instance, I can make the db open with a particular form up - but it makes it hard to add new objects. Compact/Repair database doesn't help - in fact, it might have caused it. The db is just the program/form front end for a 350MB data-containing database, and I...
1
1574
by: matthew.macdonald-wallace | last post by:
Hi all, I'm trying to add functionality to an app written in C# so that a list of people is displayed in a list box on the left hand side and then selected individuals can be added to another list box on the right-hand side. I've got the data from my database into a database reader and I can get it into an arrayList, however I can't get it to do what I want! :)
2
2024
by: G Gerard | last post by:
Hello I am trying to connect to a msaccess database and then create a list of the objects in that database (more specifically the tables) and then create a list of the fields (including the field type) for each table.
0
1846
by: Jeff | last post by:
ASP.NET 2.0 My webpage has a GridView showing rows from a table in the database. All these rows are stored in the session object -what's actually stored is generic list of objects, as this: List<Messagemessages = null; messages = (List<Message>)HttpContext.Current.Session; The user should be able to mark one or several rows in the GridView and select Delete. I wonder how I should implement deleting of the rows. Okay I
1
2102
by: smoothmunkey | last post by:
I want to make a switchboard with a list box to open objects... but i want the list box to be dynamic (as new queries or forms are created, i want them added). so far i have a combo box that selects the type of object (tables, forms, etc.) and a list box that lists all the objects of the type selected in the combo box. but i cannot figure out how to open the objects out of the list box. any help would be much appreciated. (the idea behind the...
10
6579
by: AZRebelCowgirl73 | last post by:
This is what I have so far: My program! import java.util.*; import java.lang.*; import java.io.*; import ch06.lists.*; public class UIandDB {
0
5697
by: jappenzeller | last post by:
We're using the HttpRuntime Cache for our objects and we're trying to do the following. We pull lists of objects from the database and put them in cache. We put a reference to the list in cache, but we also put references to the individual items so we can access them without having to search the lists. The objects and lists each have unique identifiers. The issue is when we want to update the object. Lets say we pull an individual...
1
1592
by: krishna81m | last post by:
I am unable to create a list of objects dynamically. I run a SQL query on the database and populate objects of types that I also know aprior. I read the query as a string, run it on the database and want to be able to populate these objects of classes whose names are known to me also based on the type of the query. In this query, SomeClass is a variable. Class myClass = Class.forName("SomeClass"); Object myClassObj =...
0
9589
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
9423
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
10216
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9997
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
9865
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5309
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3965
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
3
2815
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.