提取文本数据并按指定格式输出
set in_f "./in.f
set out_f "./out.f"
set in_con [open $in_f r]
set out_con [open $out_f w]
set pattern "Beginpoint"
while {[gets $in_con line] != -1} {
if { [regexp $pattern $line ] == 1 } {
set list1 [lindex [split $line " "] 1]
set list1 [lindex [split $line " "] 3]
lappend list "from $list1 to $list2"
}
}
foreach i $list {
puts $out_con $i
}
close $out_con
该脚本读取指定文件中的内容,通过正则表达式匹配关键词Beginpoint,然后提取并组合第1和3个字段,将结果存储到新列表中。最后,将列表内容写入新的输出文件。整个过程涉及文件I/O操作和数据处理。
1736

被折叠的 条评论
为什么被折叠?



