Satimage Previous | Next
Extracting numerical data
Home Documentation Smile Computing Data import/export ASCII data files Extracting numerical data  
Smile's command for extracting numerical data out of a string is extractcolumn.
  • extractcolumn processes a string formatted with tab as the columns separator and CR or LF as the rows separator. The in parameter may be either that string itself or a reference to a file containing such a string.
  • To specify the columns to extract, use one of the three forms extractcolumn i (will return the column index i), extractcolumn i thru j (will return the list of the columns from index i to j), or extractcolumn {i1, i2, ..., iN} (will return the list of the columns whose indexes are specified in the list). Use the skipping parameter to skip, for instance a header row.
    set {x, y} to extractcolumn {1, 3} in s skipping 1
  • By default extractcolumn returns each column as a return-delimited string. To get each column as a list of numbers, specify extractcolumn [...] as array of real.
    array of real is the name of the packed array structure that Smile uses to store and process arrays of numbers. array of real is logically equivalent to an AppleScript list of real numbers such as {1.0, 3.14, 1.414}.
    set {x, y} to extractcolumn {1, 3} in s as array of real skipping 1
  • To extract a 2d sub-array out of a 2d array as a string, specify extractcolumn [...] as string. This will return the columns as one sub-table, one tab- and return-delimited string.
    set theTable to "Year    Inc.    %
    2018    708    .3
    2019    712    .6"
    extractcolumn 2 thru 3 in theTable as string
      -- Result:
    "Inc.    %
    708    .3
    712    .6"
  • If you specify a non-existing column index, extractcolumn returns a column with empty strings if the in parameter is a string or a file, or it returns an array of real filled with one missing value if the in parameter is a matrix.
    The locations where no valid number could be found (locations that contain either an empty string or a string that cannot be made into a number) are filled with missing value's, too.
Version française
Copyright ©2008 Paris, Satimage