Question

I have a bunch of python objects with fields containing arrays of various dimensions and data types (ints or floats) and I want to write this to a file which I can read into C# objects elsewhere. I'm probably just going to write an XML file, but I thought there might be a quicker/easier way saving and reading it. Also, the resulting XML file will be rather large, which I would like to avoid if it is not too much hassle.

Is there a tried and tested file format that is compatible (and simple to use) with both languages?

Was it helpful?

Solution 2

Because you are working with floats etc.. I would consider looking at a format like BSON - "BSON is a binary format in which zero or more key/value pairs are stored as a single entity." It allows you to specify types, sizes etc...

http://bsonspec.org/#/specification

There are libraries for python, C# etc....

There are a heap of other compact easier to use than xml formats like bson out there. I only suggested this particular one as it was the first I remembered.

OTHER TIPS

What you are trying to do is called serialization. JSON is an excellent option for doing this with support in both languages.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top