Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I can't find the right way and hope that you can help me.

I need to use input files for my C# program. The file consists of some info in the beginning and is followed by a big table. It's a calibration file.

I also need to generate an equal file for the test results. For example, the date of testing used calibration file and then a table with the result.

What is the best way to do this? With XML or the old way like an INI file. Or maybe there's a better way? Feel free to give me advice.

Below is an example of how we performed it before.

What I have tried:

[CONFIG]
AMPLIFIER=AR75A400
LAB=WEBER
RFSWITCH2=LÄGE2
INFO0=ISO11452-2
DATE=2013-11-15
DATE=2013-11-15
INFO8=504158 F-140 A  
DATE=2013-11-15
INFO1=2013-11-15
INFO12=503872 Webers BCI-kabel
INFO13=901290 Blå duschslang
INFO14=900220 10 dB

[CALIBRATION]
UNIT=mA
ATTFIX=auto
LEVEL=60
TYPE=FWDTOVOLT

[CALTABLE]
Name=Calibration file
Text=
Rows=124
Columns=5
High=4.000E+08
Low=1.000E+06
Table=
4.000e+08	-9.10	39.84	09.55	60.00
3.809e+08	-9.16	39.50	10.90	60.00
3.628e+08	-10.70	39.38	12.67	60.00
3.455e+08	-10.69	39.14	12.06	60.00
3.290e+08	-9.85	39.02	08.27	60.00
3.134e+08	-10.63	38.83	10.74	60.00
2.984e+08	-10.68	38.74	09.41	60.00
2.842e+08	-10.66	38.63	07.81	60.00
2.707e+08	-10.47	38.50	14.55	60.00
2.578e+08	-10.52	38.54	07.79	60.00
2.455e+08	-11.14	38.47	13.19	60.00
2.338e+08	-11.12	38.51	14.71	60.00
2.227e+08	-11.36	38.74	08.46	60.00
2.121e+08	-10.34	39.25	10.25	60.00
2.020e+08	-8.43	40.31	17.84	60.00
1.924e+08	-6.37	41.81	16.17	60.00
1.832e+08	-6.78	40.86	15.29	60.00
1.745e+08	-8.24	39.39	15.29	60.00
1.662e+08	-9.14	38.62	15.25	60.00
1.582e+08	-9.90	38.17	11.77	60.00
1.507e+08	-10.72	37.85	08.62	60.00
1.435e+08	-11.37	37.60	07.58	60.00
1.367e+08	-11.89	37.39	12.38	60.00
1.302e+08	-12.22	37.47	11.71	60.00
1.240e+08	-12.30	37.65	09.42	60.00
1.181e+08	-12.08	37.75	09.74	60.00
1.124e+08	-11.90	37.78	10.34	60.00
1.071e+08	-11.61	37.78	06.29	60.00
1.020e+08	-11.14	37.76	13.00	60.00
9.717e+07	-10.88	37.75	07.84	60.00
9.255e+07	-10.58	37.76	12.41	60.00
8.814e+07	-10.41	37.74	07.58	60.00
8.394e+07	-10.47	37.71	13.13	60.00
7.994e+07	-10.33	37.63	08.10	60.00
7.614e+07	-10.36	37.57	11.30	60.00
7.251e+07	-10.48	37.55	09.30	60.00
Posted
Updated 1-Feb-22 7:34am
v2

I'd use either XML or JSON: build your classes, populate them, and XML or JSON will serialize / deserialize the file in pretty much a single line of code.

It's a lot more flexible and "developer friendly" than an INI file!
 
Share this answer
 
Comments
Niklas Arabäck 31-Jan-22 10:04am    
I have thought about this solution and you confirm that it is best, thanks for the input
OriginalGriff 31-Jan-22 10:33am    
You're welcome!
In Additional with the solution-1. As you mentioned later on it would be a big table. Write your own classes according to config files and go with either XML or JSON because these formats are human-readable, easy to parse and available in most programming languages. After that easy to enlarge our schema as when expected.
Map the configuration according to the XML:Tags or JSON:Keys names to describe the contents of the elements. So, both types of files can be useful to view, even in a simple text editor. Over XML and JSON you can check the comparison, features and examples with following link:
JSON vs XML in 2022: Comparison, Features & Example[^]
 
Share this answer
 
Comments
Niklas Arabäck 31-Jan-22 10:04am    
I have thought about this solution and you confirm that it is best, thanks for the input
M Imran Ansari 31-Jan-22 10:53am    
Great. Good Luck.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900