Hi, I am looking for a way to convert a List of floating point numbers
to and from text. I am embedding it in an XML document and am looking
for a neat way to serialise and de-serialise a list from a text node.
I can easily write something to do it manually but I wondered whether
List had native support to go to and from text.
If not List, are there any other collections/arrays that do this?
TIA
Simon 7 1749
On Thu, Nov 6, 2008 at 12:04 PM, SimonPalmer <si**********@gmail.comwrote:
Hi, I am looking for a way to convert a List of floating point numbers
to and from text. I am embedding it in an XML document and am looking
for a neat way to serialise and de-serialise a list from a text node.
I can easily write something to do it manually but I wondered whether
List had native support to go to and from text.
If not List, are there any other collections/arrays that do this?
It's not really a matter of the collection, but more a matter of
serialization format/library.
If you want the serialized representation to be human-readable, use
JSON ( http://docs.python.org/library/json.html#module-json).
If that's not a requirement, use pickle
( http://docs.python.org/library/pickl...module-pickle).
Both modules can convert simple Python data, such as your list of
floats, to a bytestream and back again.
Cheers,
Chris
--
Follow the path of the Iguana... http://rebertia.com
>
TIA
Simon
-- http://mail.python.org/mailman/listinfo/python-list
On Nov 6, 8:11*pm, "Chris Rebert" <c...@rebertia.comwrote:
On Thu, Nov 6, 2008 at 12:04 PM, SimonPalmer <simon.pal...@gmail.comwrote:
Hi, I am looking for a way to convert a List of floating point numbers
to and from text. *I am embedding it in an XML document and am looking
for a neat way to serialise and de-serialise a list from a text node.
I can easily write something to do it manually but I wondered whether
List had native support to go to and from text.
If not List, are there any other collections/arrays that do this?
It's not really a matter of the collection, but more a matter of
serialization format/library.
If you want the serialized representation to be human-readable, use
JSON (http://docs.python.org/library/json.html#module-json).
If that's not a requirement, use pickle
(http://docs.python.org/library/pickl...module-pickle).
Both modules can convert simple Python data, such as your list of
floats, to a bytestream and back again.
Cheers,
Chris
--
Follow the path of the Iguana...http://rebertia.com
TIA
Simon
-- http://mail.python.org/mailman/listinfo/python-list
I looked at pickle, but the problem is that I want my XML to be
readable by languages other than python, so it sort of precludes it.
JSON would be perfect, but I think the module only exists in 2.6, is
that right? Unfortunately I am bound to 2.4.
It is looking more and more like I am going to have to roll my own.
On Thu, Nov 6, 2008 at 12:18 PM, SimonPalmer <si**********@gmail.comwrote:
On Nov 6, 8:11 pm, "Chris Rebert" <c...@rebertia.comwrote:
>On Thu, Nov 6, 2008 at 12:04 PM, SimonPalmer <simon.pal...@gmail.comwrote:
Hi, I am looking for a way to convert a List of floating point numbers
to and from text. I am embedding it in an XML document and am looking
for a neat way to serialise and de-serialise a list from a text node.
I can easily write something to do it manually but I wondered whether
List had native support to go to and from text.
If not List, are there any other collections/arrays that do this?
It's not really a matter of the collection, but more a matter of serialization format/library.
If you want the serialized representation to be human-readable, use JSON (http://docs.python.org/library/json.html#module-json). If that's not a requirement, use pickle (http://docs.python.org/library/pickl...module-pickle). Both modules can convert simple Python data, such as your list of floats, to a bytestream and back again.
Cheers, Chris -- Follow the path of the Iguana...http://rebertia.com
TIA
Simon
-- http://mail.python.org/mailman/listinfo/python-list
I looked at pickle, but the problem is that I want my XML to be
readable by languages other than python, so it sort of precludes it.
JSON would be perfect, but I think the module only exists in 2.6, is
that right? Unfortunately I am bound to 2.4.
It is looking more and more like I am going to have to roll my own.
The module is available as a third-party library for previous Python
versions at http://www.undefined.org/python/
Cheers,
Chris
--
Follow the path of the Iguana... http://rebertia.com
SimonPalmer <si**********@gmail.comwrites:
I looked at pickle, but the problem is that I want my XML to be
readable by languages other than python, so it sort of precludes it.
JSON would be perfect, but I think the module only exists in 2.6, is
that right? Unfortunately I am bound to 2.4.
Simpljson is a package for python 2.3+: http://pypi.python.org/pypi/simplejson/
--
Arnaud
On Nov 6, 2:18*pm, SimonPalmer <simon.pal...@gmail.comwrote:
On Nov 6, 8:11*pm, "Chris Rebert" <c...@rebertia.comwrote:
On Thu, Nov 6, 2008 at 12:04 PM, SimonPalmer <simon.pal...@gmail.comwrote:
Hi, I am looking for a way to convert a List of floating point numbers
to and from text. *I am embedding it in an XML document and am looking
for a neat way to serialise and de-serialise a list from a text node.
I can easily write something to do it manually but I wondered whether
List had native support to go to and from text.
If not List, are there any other collections/arrays that do this?
It's not really a matter of the collection, but more a matter of
serialization format/library.
If you want the serialized representation to be human-readable, use
JSON (http://docs.python.org/library/json.html#module-json).
If that's not a requirement, use pickle
(http://docs.python.org/library/pickl...module-pickle).
Both modules can convert simple Python data, such as your list of
floats, to a bytestream and back again.
Cheers,
Chris
--
Follow the path of the Iguana...http://rebertia.com
TIA
Simon
--
>http://mail.python.org/mailman/listinfo/python-list
I looked at pickle, but the problem is that I want my XML to be
readable by languages other than python, so it sort of precludes it.
JSON would be perfect, but I think the module only exists in 2.6, is
that right? *Unfortunately I am bound to 2.4.
It is looking more and more like I am going to have to roll my own.
There is PyYAML, yet-another-markup-language. Bindings go all the way
back to 2.3. http://pyyaml.org/wiki/PyYAML
You can always just do ' '.join( alist ) to store, and
astring.split( ) to load.
On Nov 7, 7:04*am, SimonPalmer <simon.pal...@gmail.comwrote:
Hi, I am looking for a way to convert a List of floating point numbers
to and from text. *I am embedding it in an XML document and am looking
for a neat way to serialise and de-serialise a list from a text node.
I can easily write something to do it manually but I wondered whether
List had native support to go to and from text.
If not List, are there any other collections/arrays that do this?
What is "List"? Do you mean "list"?
Don't wonder, read the docs.
If you think you can easily write something to do it manually, do so,
and show us the result -- this might help establish exactly what you
mean.
Here's my attempt at doing manually what I think you mean:
| Python 2.1.3 (#35, Apr 8 2002, 17:47:50) [MSC 32 bit (Intel)] on
win32
| >>L = [1.2, -3.456, 1.0/3]
| >>L
| [1.2, -3.456, 0.33333333333333331]
| >>t = ' '.join(map(repr, L))
| >>t
| '1.2 -3.456 0.33333333333333331'
| >>L2 = map(float, t.split())
| >>L2 == L
| 1
| >>>
|
Key features:
* works on older versions of Python
* no imports required
* use of repr() means no loss of significance
* simple text format can be processed easily/manually in just about
any language
HTH,
John
On Nov 6, 8:33*pm, "Chris Rebert" <c...@rebertia.comwrote:
On Thu, Nov 6, 2008 at 12:18 PM, SimonPalmer <simon.pal...@gmail.comwrote:
On Nov 6, 8:11 pm, "Chris Rebert" <c...@rebertia.comwrote:
On Thu, Nov 6, 2008 at 12:04 PM, SimonPalmer <simon.pal...@gmail.comwrote:
Hi, I am looking for a way to convert a List of floating point numbers
to and from text. *I am embedding it in an XML document and am looking
for a neat way to serialise and de-serialise a list from a text node..
I can easily write something to do it manually but I wondered whether
List had native support to go to and from text.
If not List, are there any other collections/arrays that do this?
It's not really a matter of the collection, but more a matter of
serialization format/library.
If you want the serialized representation to be human-readable, use
JSON (http://docs.python.org/library/json.html#module-json).
If that's not a requirement, use pickle
(http://docs.python.org/library/pickl...module-pickle).
Both modules can convert simple Python data, such as your list of
floats, to a bytestream and back again.
Cheers,
Chris
--
Follow the path of the Iguana...http://rebertia.com
TIA
Simon
-- http://mail.python.org/mailman/listinfo/python-list
I looked at pickle, but the problem is that I want my XML to be
readable by languages other than python, so it sort of precludes it.
JSON would be perfect, but I think the module only exists in 2.6, is
that right? *Unfortunately I am bound to 2.4.
It is looking more and more like I am going to have to roll my own.
The module is available as a third-party library for previous Python
versions athttp://www.undefined.org/python/
Cheers,
Chris
--
Follow the path of the Iguana...http://rebertia.com
simplejson did the trick.
the trouble with a couple of suggestions is that they are only really
any good for 1 dimensional lists, although I confess I didn't make
that requirement clear in my original question
sorry for capitalising list, my mistake, hope you weren't too confused. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: John N. |
last post by:
Hi All,
Here I have a linked list each containing a char and is double linked.
Then I have a pointer to an item in that list which is the current
insertion point.
In this funtion, the user hits the right
and left keys to move this insertion point (cursor)
Here is the problem:
|
by: Kay |
last post by:
Hello,
I have two list boxes on my form, one initially displays blank, and through
javascript it is possible to move items from one box to another, this works
fine, I followed an article titled "How to move items between Lists with
Javascript" http://www.devx.com/GetHelpOn/10MinuteSolution/16372. My problem
is that I also have a dropdown...
|
by: Kay |
last post by:
Hello,
I have two list boxes on my form, one initially displays with items and the
other displays blank, by clicking a button, it is possible to move items
from one box to another and vice a versa, this works fine. I also have a
dropdown list on the page with autopost back = true, my problem is as
follows: when the user selects an option in...
|
by: Brian Henry |
last post by:
I have two list boxes on my form... lstCanSend and lstRecipients... well
then there are two buttons add and remove between them (your basic select
and pick listing) which uses java script to move the items between list
boxes (the listbox controls are server side ones with runat=server set on
them, the buttons are basic html button i dont want...
|
by: JB |
last post by:
I've created a generic of type List<T> where T is a custom class. I
need to use the List<T>.Contains method. I know I need to implement
the IEqualityComparer but I can't seem to get the Contains method to
execute my Equals code. What am I doing wrong?
T is the following
NameValue : IEqualityComparer<NameValue>
{
public string Text;
| |
by: David Trimboli |
last post by:
Suppose I've got HTML with the following in it:
<ul class="navigation">
<li><a href="chapter1.html" title="Chapter 1">Previous</a></li>
<li><a href="./">Contents</a></li>
<li><a href="chapter3.html" title="Chapter 3">Next</a></li>
</ul>
I'd like to style this such that all three links appear on the same
line, with Prev at the far left,...
|
by: rn5a |
last post by:
A Form has 2 select lists. The 1st one whose size is 5 (meaning 5
options are shown at any given time) allows multiple selection whereas
the 2nd one allows only 1 option to be selected at a time.
When an option is selected in the 2nd select list, the ASP page posts
itself. Assume that the 1st select list has the following 10 options
(note...
|
by: trose178 |
last post by:
Good day all, I am working on a multi-select list box for a standard
question checklist database and I am running into a syntax error in
the code that I cannot seem to correct. I will also note that I am
using Allen Browne's multi-select list box for a report as a guide. I
should also note that my access skills are not the best so I may need...
|
by: ADezii |
last post by:
This week’s Tip of the Week will clearly demonstrate how you can dynamically set the Drop Down List Width of a Combo Box to the length of the longest item in its Row Source. The inspiration for this Tip came from one of our own resident Experts, mshmyob. In response to a Thread relating to this very Topic, mshmyob came up with a rather ingenious...
|
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...
|
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...
| |
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. ...
|
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...
|
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...
|
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...
|
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...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |