astro py:docs

- Index
- Modules

### Navigation

- next »
- « previous |
- Astropy v1.1.1 »
- ASCII Tables (`astropy.io.ascii`) »
- Csv

# Csv

class `astropy.io.ascii.``Csv`

  Bases: `astropy.io.ascii.Basic`

  Read a CSV (comma-separated-values) file.

  Example:

      num,ra,dec,radius,mag
      1,32.23222,10.1211,0.8,18.1
      2,38.12321,-88.1321,2.2,17.0

  Plain csv (comma separated value) files typically contain as many entries as there are columns on each line. In contrast, common spreadsheet editors stop writing if all remaining cells on a line are empty, which can lead to lines where the rightmost entries are missing. This Reader can deal with such files. Masked values (indicated by an empty ‘’ field value when reading) are written out in the same way with an empty (‘’) field. This is different from the typical default for `astropy.io.ascii` in which missing values are indicated by `--`.

  Example:

      num,ra,dec,radius,mag
      1,32.23222,10.1211
      2,38.12321,-88.1321,2.2,17.0

  Methods Summary

  `inconsistent_handler`(str_vals, ncols) | Adjust row if it is too short.

  Methods Documentation

  `inconsistent_handler`(str_vals, ncols)

    Adjust row if it is too short.

    If a data row is shorter than the header, add empty values to make it the right length. Note that this will not be called if the row already matches the header.

    Parameters:

    str_vals : list

    > A list of value strings from the current row of the table.

    ncols : int

    > The expected number of entries from the table header.

    Returns:

    str_vals : list

    > List of strings to be parsed into data entries in the output table.