col1,col2,col3
value A1,value A2,value A3
value B1, value B2 ,value B3
以下のコードは、このファイルを読み取り、これを使用してスナップショットを作成し、簡単なコメントをターミナルに書き込みます。使用される引数がファイル名および列区切りのみであることに注意してください。
set filename="c:/demo.txt"
set snap=##class(EnsLib.SQL.Snapshot).%New()
do snap.ImportFile(filename,,",")
d show
quit
show
w "number of rows in snapshot=",snap.RowCount,!
while snap.Next()
{
w "current row=",snap.%CurrentRow,!
w "data in first column=",snap.GetData(1),!
w "data in second column=",snap.GetData(2),!
w "data in third column=",snap.GetData(3),!
}
quit
number of rows in snapshot=3
current row=1
data in first column=col1
data in second column=col2
data in third column=col3
current row=2
data in first column=value A1
data in second column=value A2
data in third column=value A3
current row=3
data in first column=value B1
data in second column=value B2
data in third column=value B3