フィルターのクリア

extracting data from .ags file

11 ビュー (過去 30 日間)
Lieke van Boxtel
Lieke van Boxtel 2023 年 12 月 7 日
回答済み: Cris LaPierre 2023 年 12 月 7 日
I am looking to get data from .ags files (a kind of text file). The data is in different blocks with enters seperating those blocks and all blocks represent tables with the first line as the name and the rest in table format with commas seperating columns.
Which function and import options could I use to get the seperate tables? I just need a way to start, as I tried using readtable, textscan and the import data button, which doesnt show the file as an option. I also used readlines, that did give me all the lines in seperate cells as strings, but I was not able to create the tables. I added a small part of the data to show how it looks.
  3 件のコメント
jessupj
jessupj 2023 年 12 月 7 日
編集済み: jessupj 2023 年 12 月 7 日
long ago, i had written a script to convert *.ags geotech files with specfic content to csv but i'd used the system shell tools (e.g. awk, sed, etc).
If i had to do it all over again, i'd check
and see if i could use the Bentley ags --> csv converter, and then readtable from within matlab.

サインインしてコメントする。

回答 (1 件)

Cris LaPierre
Cris LaPierre 2023 年 12 月 7 日
Not pretty, but here's a quick and dirty template you can use to import AGS files. Since it appears the number of tables in the file can vary, I return the tables in a structure. If you prefer each table be a separate workspace variable, you can uncomment the assignin line of code on line 70.
Again, this is only meant to help get started. It is not extensively tested.
unzip('Show data.zip')
agsS = loadAGS('Show data.ags')
agsS = struct with fields:
PROJ: [1×7 table] TRAN: [1×10 table] LOCA: [17×16 table] HDPH: [72×9 table] SCPG: [56×20 table] SCPT: [187×23 table] SCDG: [34×9 table] SCDT: [33×6 table]
agsS.SCDT
ans = 33×6 table
LOCA_ID SCPG_TESN SCDG_DPTH SCDT_SECS SCDT_RES SCDT_PWP2 _____________ _____________ _________ _________ ________ _________ "IJV001-PCPT" "IJV001-PCPT" 11.19 0 2.337 0.0591 "IJV001-PCPT" "IJV001-PCPT" 11.19 0.5 2.177 0.0701 "IJV001-PCPT" "IJV001-PCPT" 11.19 1 2.108 0.0788 "IJV001-PCPT" "IJV001-PCPT" 11.19 1.5 2.069 0.0866 "IJV001-PCPT" "IJV001-PCPT" 11.19 2 2.033 0.0936 "IJV001-PCPT" "IJV001-PCPT" 11.19 2.5 1.999 0.1003 "IJV001-PCPT" "IJV001-PCPT" 11.19 3 1.972 0.1064 "IJV001-PCPT" "IJV001-PCPT" 11.19 3.5 1.944 0.1122 "IJV001-PCPT" "IJV001-PCPT" 11.19 4 1.925 0.1176 "IJV001-PCPT" "IJV001-PCPT" 11.19 4.5 1.905 0.1227 "IJV001-PCPT" "IJV001-PCPT" 11.19 5 1.886 0.1277 "IJV001-PCPT" "IJV001-PCPT" 11.19 5.5 1.871 0.1321 "IJV001-PCPT" "IJV001-PCPT" 11.19 6 1.855 0.1361 "IJV001-PCPT" "IJV001-PCPT" 11.19 6.5 1.836 0.1401 "IJV001-PCPT" "IJV001-PCPT" 11.19 7 1.822 0.1436 "IJV001-PCPT" "IJV001-PCPT" 11.19 7.5 1.806 0.1469

カテゴリ

Help Center および File ExchangeTables についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by