Export a sample to a CSV fileΒΆ

In this basic example we are going to export a sample to a CSV file.

In [26]:
from __future__ import print_function
import openturns as ot

# create a sample from a 2-d gaussian distribution
sample = ot.Normal(2).getSample(5)
sample.setDescription(['u1', 'u2'])
In [27]:
# default separator is ';'
sample.exportToCSVFile('sample.csv', ',')
In [28]:
# print the content of the file
with open('sample.csv', 'r') as f:
    for line in f.readlines():
        print(line, end='')