필터 지우기
필터 지우기

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 CenterFile Exchange에서 Tables에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by