I have a C# application that needs to be run several thousand times. Currently it precomputes a large table of constant values at the start of the run for reference. As these values will be the same from run to run I would like to compute them independently in a simple python script and then just have the C# app import the file at the start of each run.
The table consists of a sorted 2D array (500-3000+ rows/columns) of simple (int x, double y) tuples. I am looking for recommendations concerning the best/simplest way to store and then import this data. For example, I could store the data in a text file like this “(x1,y1)|(x2,y2)|(x3,y3)|…|(xn,yn)” This seems like a very ugly solution to a problem that seems to lend itself to a specific data structure or library I am currently unaware of. Any suggestions would be welcome.
I would go for a simplified csv file.
Given that all your values are numbers, you can read them in C# using
You can find more C# options for csv here
On Python you can use the
csvmodule to read and write them. Better explanation here, but the short of it isUsing CSV also gives you flexibility for future improvements, as well as exporting and importing from other programs like Excel for further processing.