X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 29 Mar 2007 10:12 AM by  anon
Sorry... We have file_lines for lines(rows) in IDL. What about file_columns?
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
29 Mar 2007 10:12 AM
    I posted similar message below yesterday, but I am really sorry for my language mistake. English is not my mother tongue, and my language is totally different from English. For this reason, I am doing this kind of stupid mistakes sometimes. I rewrote my posting. Please understand me... Please ignore the other question below. T.T What I was trying to know was on 'file_columns'. We can easily figure out how many lines(rows) in IDL using File_line function. However, at least in my knowledge, there is no 'file_columns' in IDL. Sometimes I have to count the numbers of a big data file, but do I have to do it manually even in IDL? Harry from Korea

    Deleted User



    New Member


    Posts:
    New Member


    --
    29 Mar 2007 10:12 AM
    There is no FILE_COLUMNS probably because there is no worldwide standardized way to represent columns in ASCII data files. For some data files a 'comma' indicates the end of one column and the beginning of the next, For others it might be a single blank-space char. For yet others it might be a tab character, or it might be that the 27th character on the line starts a new column. It is for this reason that IDL implemented the ASCII_TEMPLATE function that gives users a quick way to interactively create a reader for a particular ASCII data column format. Here is some simple code that could provide FILE_COLUMNS functionality, if you know that your ASCII data files are all data (no header - though you could easily modify my code to implement that), that columns are demarcated by blank space chars or commas (and blank space chars or commas are never part of the data "payload"), and that every line (row) has the same number of column elements: FUNCTION FILE_COLUMNS, asciiDataFile openr, lun, asciiDataFile, /GET_LUN testLine = '' readf, lun, testLine ; Read the first line of the file free_lun, lun ; Create the regular expression for finding separators separatorList = '[ ' + string(9b) + ',]' ; Look for blank space, tab, comma columnStarts = strsplit(testLine, separatorList, /REGEX) return, n_elements(columnStarts) END James Jones
    You are not authorized to post a reply.