class CSV[source]

Bases: openpnm.io.GenericIO.GenericIO

Reads and writes CSV (comma-separated-value files) containing pore and throat data


There are a few rules governing how the data is be stored:

1. The first row of the file (column headers) must contain the property names. The subsequent rows contain the data.

2. The property names should be in the usual OpenPNM format, such as of pore.volume or throat.surface_area.

3. Each column represents a specific property. For Np x 1 or Nt x 1 data such as pore.volume this is straightforward. For Np x m or Nt x m data, each of the m columns should have their own column in in the CSV file, with a numpy-style index indicating which axis it corresponds to. For instance, the pore.coords values should be stored as three separate columns with the headings: pore.coords[0], pore.coords[1], and pore.coords[2]. OpenPNM will convert that back into an Np x m array upon loading.

  1. The file can contain both or either pore and throat data.

5. Labels can be imported by placing the characters TRUE and FALSE in a column corresponding to the label name (i.e. pore.front). TRUE indicates where the label applies and FALSE otherwise.

classmethod export_data(network=None, phases=[], filename='', delim=' | ')[source]

Save all the pore and throat property data on the Network (and optionally on any Phases objects) to CSV files.

  • network (OpenPNM Network) – The Network containing the data to be stored

  • phases (list of OpenPNM Phases (optional)) – The Phases whose data should be stored.

  • filename (string or path object) – The name of the file to store the data


The data from all Geometry objects is added to the file automatically.

classmethod import_data(filename, project=None, delim=' | ')[source]

Opens a ‘csv’ file, reads in the data, and adds it to the Network

  • filename (string (optional)) – The name of the file containing the data to import. The formatting of this file is outlined below.

  • project (OpenPNM Project object) – A GenericNetwork is created and added to the specified Project. If no Project object is supplied then one will be created and returned.


project – An OpenPNM project containing the data assigned to Generic versions of the objects from which it was exported.

Return type