hi everybody,
I have data under matrix form in a text file as follows:
<tab> 1 <tab> 2 <tab> 3 <tab> 4 <tab> 5 <tab> 6 <tab> 7 <tab>
1<tab> <tab> F <tab> <tab> F <tab> F <tab> F <tab> F <tab>
2<tab> F <tab> F <tab> F <tab> F <tab> F <tab> F <tab> F <tab>
3<tab> <tab> <tab> F <tab> <tab> F <tab> F <tab> <tab>
4<tab> <tab> F <tab> F <tab> F <tab> <tab> F <tab> F <tab>
5<tab> F <tab> F <tab> F <tab> <tab> F <tab> F <tab> F <tab>
where f is a data of typ double. and (1,2,3,4,5,6) and (1,2,3,4,5) are i and j indeces
when I try to read the data using matrix form i.e: tab[i][j] I get a mess of data
because of the some missing data like, tab[1][1]= emty,,,,
Please, can anyone tell me how to overcome this problem?
If your floats will be limited to a certain range, you could define an error value. For example, if all your floats should be positive, you can set your error value to -1. Then, check for that value and handle it any way you like.
What exactly are you trying to do?
Do you already have the data structure? If so, what is it? Your notation makes me believe it's a 2D array, in which case I don't see the problem.
Are you trying to read in a text file into a data structure? I'm not sure C++'s file handling distinguishes between 1 or 2 tabs. Maybe you can try converting it through Excel or something. I suggest a CSV file, which separates tabs/cells by means of a ',' or ';'. This allows you to read it in by using that character as a separator, as C++ can obviously distinguish between 1 or 2 ;'s.
what I 'm doing is manipulating a 2D array of data that is stored in a text file but that contains planty of empty locations (missing data, can't be controlled)
I'm not sure why you think reading from CSV files would be slower than regular text files. After all, CSV files are regular text files, with the guarantee that comma's were used as field separators. Just because they can be interpreted differently, doesn't mean they're "more advanced" than text files. I see no reason why they would be slower.
CSV files are slower to be processed because the µP have to read the "," and check if it's not a decimal point since in the french system it's considered so, which means an additional operation for the µP.
Morever, i have a problem with retriving the data of type double from CSV files, if you have a simple trick to do that, I 'll be awsome for me.
Your argument for "slower" is nonsense. The compiler doesn't check for meaning. A ',' is a ','. There is no reason for slowdown.
My Excel has three CSV types available in the "Save As" window. All three result in ';' as the item separator. ';' is never a problem as far as interpretation goes. I'm using a European version of Excel, but I'm guessing at least one of the options on any version will use ';' as separator. (I'd even go as far as gamble that all of them do.)