0

Hi I am using the following code to get data from a library file which is generated from synopsys. I am using tcl to code.

set file [open "my_file.lib r]
set final [read -nonewline $file]
close $file

This code is not working for me. It is a library file so I want to know if there is error in my code or in the library. Please help me with this.

Thanks

Hai Vu
  • 37,849
  • 11
  • 66
  • 93
user2533429
  • 175
  • 1
  • 6
  • 13
  • What do you mean by **not working**? Is there any error? What are your goals here? Looking at the code, you are trying to read the contents of a file, but what really are your goals? – Hai Vu Jul 01 '13 at 23:56
  • Ya i am trying to read the file so that I can get the required selected data from the file and use it for sorting. I will have to use a while or for loop to fetch the required data from the file. Thats my aim. This code is not recognizing the file at all. So I dont knw if the code is wrong or some issue with the file. – user2533429 Jul 02 '13 at 02:53
  • I am sorry, but what did you meant by **not recognize the file**? Is it file not found? – Hai Vu Jul 02 '13 at 04:34
  • What _exact_ error message is it producing, if any? – Donal Fellows Jul 02 '13 at 14:42

2 Answers2

1

use this to read .lib file

set file [open "filename.lib" r] #or if u are in another folder from file directory then use full path of the .lib file

set filedata [read $file]

puts "$filedata"

close $file

0

What is a "library file"? is it just text or is it a binary file? If it has binary data, you could do this:

set filename my_file.lib
set file [open $filename r]
fconfigure $file -translation binary
set final [read $file [file size $filename]]
close $file
glenn jackman
  • 238,783
  • 38
  • 220
  • 352
  • The error I am getting is the following : no such file or directory Use error_info for more info. (CMD-013) The library is text file and it is pretty huge. – user2533429 Jul 02 '13 at 15:55
  • use `[file exists]` before trying to open it. If it's huge, are you sure you need to read the whole thing into memory? – glenn jackman Jul 02 '13 at 16:45