X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 28 Mar 2007 08:55 AM by  anon
We have file_lines for lines in IDL. What about file_rows?
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
28 Mar 2007 08:55 AM
    I know there is an excellent functions to count the number of lines of data file... What about file_rows? Is there any functions to check the number of rows? If there is no functions, what do you do if you want to have the number of rows of a big data file, for example, (*, 169245)?

    Deleted User



    New Member


    Posts:
    New Member


    --
    28 Mar 2007 08:55 AM
    In ASCII data, "file_rows" ***is*** "file_lines". A row is demarcated by by a "newline" character(s) and that is exactly what IDL's FILE_LINES function counts. In binary data, however, there are no common formatting rules for a "row" as there are in ASCII data. Each software or programmer has its/his/her own specification for what constitutes a row of data in a binary data file. The reader of the data needs to know this specification before the "rows" can be found. IDL has functions to check what constitutes a "row" in many different kinds of binary files, e.g in all kinds of different image files (e.g. .bmp, .png, .jpg), in all kinds of different scientific data format files (HDF, NITF, DICOM), etc. The most common kind of binary read request for IDL, though, is to read flat, binary files: Files that have just one datatype of data, and that datatype represents some particular grid of data. To read these, you, the programmer of the reader, need to program into IDL what constitutes a row of data in that file. Thus, if you knew that your binary data files have 200 8-byte double-precision floating point data samples in each row, then you could dynamically determine its number of rows and import it into IDL with the following commands: nBytes = (file_info('mydata.dat')).size elementsPerRow = 200 bytesPerRow = elementsPerRow * 8 nRows = nBytes / bytesPerRow mydata = dblarr(elementsPerRow, nRows) ; Allocate the storage for the file data openr, lun, 'mydata.dat', /GET_LUN readu, lun, mydata ; Imports the entire file into the 'mydata' array free_lun, lun James Jones
    You are not authorized to post a reply.