Using Textscan to read Sinex file rows with variable delimiters
Mostra commenti meno recenti
Hi Everyone,
I'm having trouble with reading a block of text from a sinex file, where the general delimiter seems to be a space but then there are two columns where this is changeable.
+SITE/ID
*CODE PT __DOMES__ T _STATION DESCRIPTION__ APPROX_LON_ APPROX_LAT_ _APP_H_
7835 A 10002S001 L Grasse, France 6 55 16.0 43 45 16.8 1322.8
7845 A 10002S002 L Grasse CDP7845 6 55 17.6 43 45 16.6 1323.3
7848 A 10077M002 L Ajaccio 8 45 45.7 41 55 38.6 97.3
7805 A 10503S001 L Metsahovi, Finland 24 23 40.3 60 13 02.3 78.2
7806 A 10503S014 L Metsahovi, Finland 24 23 40.3 60 13 01.7 74.0
7839 A 11001S002 L Graz, fixed 15 29 36.0 47 04 01.6 539.4
.
.
.
98 lines total
-SITE/ID
*
For example the station_description column has a comma in between the strings 'Grasse' and 'France', then a space between the second row 'Grasse' and 'CDP7845' and the third ends on a delimiter. I have tried using %q, collectoutput and multipledelimsasone,delims: ' ' and {' ',','} to read the lines but it seems to either stop at the first delimiter on line 1 before France, or just skip the word Ajaccio completely. The next issue is then reading the long/lat as one float effectively and I'd like to end up with two columns, one for the lat and one for long so I can use for plotting later.
The code I am currently using below: positions(2) - positions(1) is the end-start positions from my searcher that finds and points to the block within the sinex file. That works fine.
Code:
location_import = textscan(fileID(1),'%d %c %q %c %s %s',...
positions(2)-positions(1),'Delimiter',' ','MultipleDelimsAsOne',true);
Current Output:
79x1 int32 79x1 char 79x1 cell 79x1 char 79x1 cell 79x1 cell
7835 'A' 1002S001 'L' Grasse, France
6 '5' 5 '1' 6.0 43
45 '1' 6.8 '1' 322.8
7845 'A' 10002S002 'L' Grasse CDP7845
6 '5' 5 '1' 7.6 43
45 '1' 6.6 '1' 323.3
7848 'A' 10077M002 'L' Ajaccio 8
I just cant figure out the textscan command I need to get it to work, especially for the station_description formatting changes. Any help would be massively appreciated so I can learn from this.
Thanks very much!
Risposta accettata
Più risposte (1)
Simon Hunter
il 31 Dic 2021
0 voti
Categorie
Scopri di più su Standard File Formats in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!