I’ve got a datastructure that contains several hundred coordinate points that look like this:
5,234 20,789
8,687 19,576
13,783 12,032
...
Each X and Y value is separated by TABs. They are always followed by additional information in textual form. Something like:
Date and Time: 22.04.2001
Software Version: 4.8.30002.0
....
For now there are always exactly 1024 coordinate points. So I simply read out coordinates for 1024 lines. Afterwards I am simply assuming that what follow is additional information so I am reading the stuff out to strings.
So the coordinate readout-loop looks something like this:
for(i=0;i<1024;i++)
{
ReadXvalue();
DoTab();
ReadYvalue();
}
Now I want to read those files dynamically in case that points will be added or omitted.
My first thought was just to check if the symbol I am reading is a number or a char. In case it is a number it must be a coordinate point. If it is a char I assume that it is additional information. In my opinion this is somehow dirty, or at least it doesn’t feel right.
What would be a clean and smart way to do this?
Any examples, references or suggestions are welcome.
Greets,
BC++
If you have the fixed lenth columns which you have like (x, y) then i think this is more suitable way to read text files
hope fully this will be helpful to you.
you can add columns as much as you want. and the dt.rows.add(item) will add only columns in the row as it has e.g item has only two items then the row will be added with two columns only.