SlyFox
SlyFox

Reputation: 180

What is the simplest way in Python to use data that is fixed and I would be updating manually?

I am a novice writing a simple script to analyse a game. The data I would like to use describes "Items" and they have statistics associated with them (eg. "Attack Speed").

To clarify: The game is not something I have access to beyond being a player, my script is to compare combinations of the items. I will manually look up the information on each item, for example:

Name:      Bloodforge
Price:     2715
Lifesteal: 0.15
Power:     40

These items will change as they are updated in the actual game, so I am looking for a way to store/update them manually (editing text) and easily access the statistics for these items using python.

I have looked into using XML and JSON, as well as MySQL. Are there any other suggestions that might fit this usage? Which libraries should I use?

Upvotes: 0

Views: 55

Answers (2)

T.Z.
T.Z.

Reputation: 2162

Well, You got many more options. From least to most complicated :

What You should use really depends on what are Your needs exactly. If You are only starting developing game, and are novice - go for pickle or shelve (or both) for now. They are simple and will let You keep focus on game mechanics and learning python stuff. Later, when You will need something more complicated - You can move to using some relational database and go for the web with SQLAlchemy.

EDIT: Information that You provided suggest that You do not need python at all. The thing You want coud be achieved in spreadsheet. But analyzing data would be simpler in SQL, so I can recomend MySQL for it, or if You want something really simple SQLite with some managing tools, like for example this FF plugin. You can create table You need, manually create rows in it and then write some SQL query to give You statistics in the way You need.

Upvotes: 0

Secret
Secret

Reputation: 3348

Without further info, I would say to use JSON, as it's easy to use and human-readable:

{
   "Attack Speed": 5,
   "Items": ["Dirt", "Flower", "Egg"]
}

Upvotes: 1

Related Questions