Is there benefit to converting my program .CSV text-file output to xml-output?

Is there benefit to converting my program .CSV text-file output to xml-output?

I have a Fortran program that outputs simulation data by writing.CSV text files. The CSV files will give fluid-property data for collections of mesh cells. So something like the following example.

Cell Group 1 (Axial Coordinate 1)
time       sodium       chloride    ......     .......   ......
0.5          0.001          0.01       .....       ....      ...
1 0         .002            0.03        ....        ....      ...
1.5          0.004          0.05       ....        ....      ....
…..          …..           …….      ......      ......    .....

Cell Group 2 (Axial Coordinate 2)
time       sodium       chloride    ......     .......   ......
0.5          0.002          0.02       ....        ....      ...
1 0          0.003          0.04       ....        ....      ...
1.5          0.005          0.06       ....        ....      ....
…..          …..           …….      ......      ......    .....

Similarly there are other cell groups that shows pH, Rate, Conductivity etc at different axial coordinates with respect to time. The number of axial and time coordinates will depend on user input. Typically, we would want to organize this data into some graphical way in order to interpret or present it. The current version of the software uses MS excel with VBA to plot and animate the data.

For the upgradation of the software,we want the program to be able run multiple times with new user inputs. We are trying to biuld a version that can handle recylce stream i.e. use the output data from one simulation (values at final axial and time ocoordinates) and process it so that it can be used as input values for a new simulation. 

Someone in a visual basic (interface of the software is built on Visual Basic) forum suggested me to consider XML as an option. But I almost know nothing about XML. I want to figure out if it would be worth my time to learn about XML and start adding the capability to this Fortran program to write its data in XML format. Can my previous method for analyzing simulation data be improved upon by making it easier, faster, and more automatable if I started writing data to XML?

1. Would there be any advantage in switching to XML here? How would I do that? The text file like the above usually has 1000 lines of numbers of which I have shown only 2.

2. Are there advantages in speed at which XML files can be read / outputted as comopared to ASCII text-file format?

3. Or is the .CSV file format good enough for data storage for the multiple run simulations? 

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

From the Fortran point of view it will be easier to interact with csv files, if you move to xml you'll have to use a library for i/o. Well that's not quite true, you could write your own interface layer if the format is fixed but you'll probably find that the requirements expand as you're writing it!

xml has lower data density but can provide layout information as well. CSV files are easy to load into a spreadsheet and easier to read in raw form. So my answers to your questions are

1) only switch to xml if it is now important to provide layout information

2) I don't think there will be any speed advantage with the file sizes you've indicated. Note that xml files can also be ASCII text. Since an xml file corresponding to one of your csv files will be bigger it's possible xml will read slower.

3) Yes.

You should probably also consider other options that might improve you application. For example unformatted (either direct or sequential) will be faster since ther is no format conversion required by text files. If you want to access the data from different (non-sequential) times you could use direct access where one record is a row in your table. You would provbably need to provide a wrapper for VB to access but others will know more about that than me.


Another benefit of managing xml files, is the ability to support evolution of the data structure.

If you add new items to your xml structure, the change in the program is less important and the older versions of the program or third parties applications will be able to continue to read the new files as old ones.

The difficuty is that there is no xml parser in Fortran.

I have adapted an object C one to non object to be used from fortran.

Leave a Comment

Please sign in to add a comment. Not a member? Join today