24小时热门版块排行榜    

CyRhmU.jpeg
查看: 2673  |  回复: 0

3sGirl

新虫 (小有名气)

[求助] IDL中读*.prv文件出现的错误:READF: End of file encountered. Unit: 101,

各位大侠:
       您们好!

      用IDL读*.prv 文件,出现的错误:READF: End of file encountered. Unit: 101, File: G:“book.txt”  代码如下:if file_test(txtname)then begin;The FILE_TEST function checks files for existence and other attributes without having to first open the file/用来检查文件是否存在及在不打开文件的情况下检查其属性
  nLines=file_lines(txtname);file_lines()用于返回数据的行
  tmp=" ";定义一个字符串变量
   openr,lun,txtname,/get_lun   ;  打开文件
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  while(~EOF(lun))do begin;
    readf,lun,tmp;读取第一行
;         print,tmp
;         help,tmp
    Col=strsplit(tmp,/extract);拆分第一行获取列数
    ColNum=N_elements(Col)
  Arr_1=dblarr(ColNum,nLines-1);定义一个n列n-1行,元素为0的数组
   ;point_lun,lun,2
   
   readf,lun, Arr_1  ;READF requires a file unit to be explicitly specified---明确指定文件单元
   
     Arr_1=[[Col],[ Arr_1]];重新组合数组(n,n-1)+第一行=(n,n)
   
  endwhile
   print, Arr_1[*,1:*]
   
   free_lun,lun ;; Close the file and free the file unit

endif

继续您的指导,谢谢!
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 3sGirl 的主题更新
信息提示
请填处理意见