Import a sample from a CSV fileΒΆ

In this basic example we are going to import a CSV file

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

# write a csv file by hand
with open('sample.csv', 'w') as f:
    f.write('0.1, 0.2, 0.3\n')
    f.write('0.7, 8.2, 4.3\n')
In [16]:
# default separator is ';'
sample = ot.Sample.ImportFromCSVFile('sample.csv', ',')
print(sample)
    [ data_0 data_1 data_2 ]
0 : [ 0.1    0.2    0.3    ]
1 : [ 0.7    8.2    4.3    ]
In [ ]: