Csv

class astropy.io.ascii.Csv[source]

Bases: Basic

CSV (comma-separated-values) table.

This file format may contain rows with fewer entries than the number of columns, a situation that occurs in output from some spreadsheet editors. The missing entries are marked as masked in the output table.

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 --.

Since the CSV format does not formally support comments, any comments defined for the table via tbl.meta['comments'] are ignored by default. If you would still like to write those comments then include a keyword comment='#' to the write() call.

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)[source]

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_valspython:list

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

ncolspython:int

The expected number of entries from the table header.

Returns:
str_valspython:list

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