5.7.3 Routines to Edit Rows or Columns

1
Insert or delete rows in an ASCII or binary table. When inserting rows all the rows following row FROW are shifted down by NROWS rows; if FROW = 0 then the blank rows are inserted at the beginning of the table. Note that it is *not* necessary to insert rows in a table before writing data to those rows (indeed, it would be inefficient to do so). Instead one may simply write data to any row of the table, whether that row of data already exists or not.

The first delete routine deletes NROWS consecutive rows starting with row FIRSTROW. The second delete routine takes an input string that lists the rows or row ranges (e.g., '5-10,12,20-30'), whereas the third delete routine takes an input integer array that specifies each individual row to be deleted. In both latter cases, the input list of rows to delete must be sorted in ascending order. These routines update the NAXIS2 keyword to reflect the new number of rows in the table.

  int fits_insert_rows / ffirow
      (fitsfile *fptr, LONGLONG firstrow, LONGLONG nrows, > int *status)

  int fits_delete_rows / ffdrow
      (fitsfile *fptr, LONGLONG firstrow, LONGLONG nrows, > int *status)

  int fits_delete_rowrange / ffdrrg
      (fitsfile *fptr, char *rangelist, > int *status)

  int fits_delete_rowlist / ffdrws
      (fitsfile *fptr, long *rowlist, long nrows, > int *status)

  int fits_delete_rowlistll / ffdrwsll
      (fitsfile *fptr, LONGLONG *rowlist, LONGLONG nrows, > int *status)

2
Insert or delete column(s) in an ASCII or binary table. When inserting, COLNUM specifies the column number that the (first) new column should occupy in the table. NCOLS specifies how many columns are to be inserted. Any existing columns from this position and higher are shifted over to allow room for the new column(s). The index number on all the following keywords will be incremented or decremented if necessary to reflect the new position of the column(s) in the table: TBCOLn, TFORMn, TTYPEn, TUNITn, TNULLn, TSCALn, TZEROn, TDISPn, TDIMn, TLMINn, TLMAXn, TDMINn, TDMAXn, TCTYPn, TCRPXn, TCRVLn, TCDLTn, TCROTn, and TCUNIn.

  int fits_insert_col / fficol
      (fitsfile *fptr, int colnum, char *ttype, char *tform,
       > int *status)

  int fits_insert_cols / fficls
      (fitsfile *fptr, int colnum, int ncols, char **ttype,
       char **tform, > int *status)

  int fits_delete_col / ffdcol(fitsfile *fptr, int colnum, > int *status)

3
Copy column(s) between HDUs. If create_col = TRUE, then new column(s) will be inserted in the output table, starting at position `outcolumn', otherwise the existing output column(s) will be overwritten (in which case they must have a compatible data type).

The first form copies a single column incolnum to outcolnum. Copying within the same HDU is permitted. The second form copies ncols columns from the input, starting at column incolnum to the output, starting at outcolnum. For the second form, the input and output must be different HDUs.

If outcolnum is greater than the number of column in the output table, then the new column(s) will be appended to the end of the table. Note that the first column in a table is at colnum = 1. The standard indexed keywords that related to the columns (e.g., TDISPn, TUNITn, TCRPXn, TCDLTn, etc.) will also be copied.

  int fits_copy_col / ffcpcl
      (fitsfile *infptr, fitsfile *outfptr, int incolnum, int outcolnum,
       int create_col, > int *status);

  int fits_copy_cols / ffccls
      (fitsfile *infptr, fitsfile *outfptr, int incolnum, int outcolnum, 
       int ncols, int create_col, > int *status);

4
Copy 'nrows' consecutive rows from one table to another, beginning with row 'firstrow'. These rows will be appended to any existing rows in the output table. Note that the first row in a table is at row = 1.

The fits_copy_selrows form copies only selected rows to the output. Which rows are transferred is determined by an array of flags, row_status[], which could be returned by fits_find_rows() or constructed by the user. FITS row N is copied if row_status[N-first_row] is non-zero.

  int fits_copy_rows / ffcprw
      (fitsfile *infptr, fitsfile *outfptr, LONGLONG firstrow,
       LONGLONG nrows, > int *status);

  int fits_copy_selrows / ffcpsr
      (fitsfile *infptr, fitsfile *outfptr, LONGLONG firstrow,
       LONGLONG nrows, char *row_status, > int *status);

5
Modify the vector length of a binary table column (e.g., change a column from TFORMn = '1E' to '20E'). The vector length may be increased or decreased from the current value.

  int fits_modify_vector_len / ffmvec
      (fitsfile *fptr, int colnum, LONGLONG newveclen, > int *status)