Tcl_SetObjLength:负长度请求错误

时间:2018-04-04 07:13:29

标签: debugging scripting tcl file-handling

我有一个大约4200万行的文件,我试图在TCL中读取和解析。但是,在打印D1后我立即得到以下错误消息。还有其他选择来读取大文件吗?

proc test {} {
        set rpt "<file_name>"
        puts "D0"
        set lines [open $rpt r]
        puts "D1"
        set Data [read $lines]
        puts "D2"
        close $lines
}

输出错误:

D0
D1
Tcl_SetObjLength: negative length requested: -2147483646 (integer overflow?)

1 个答案:

答案 0 :(得分:2)

set fp [open inputfile r]
# Read one line at a time
while {[gets $fp line]!=-1} {
    puts $line
}
close $fp