File: t_Sample_csv_fr.py

package info (click to toggle)
openturns 1.24-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 66,204 kB
  • sloc: cpp: 256,662; python: 63,381; ansic: 4,414; javascript: 406; sh: 180; xml: 164; yacc: 123; makefile: 98; lex: 55
file content (19 lines) | stat: -rwxr-xr-x 493 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#! /usr/bin/env python

import openturns as ot
import os

ot.TESTPREAMBLE()

# "Le French way"
fname = "sample_fr.csv"
with open(fname, "w") as f:
    f.write("X1;X2;X3;X4\n-1,2;2,3;3,4;-4,5\n5,6;-6,7;7,8;8,9\n-0,1;3,2;5,1;7,5\n")
aSample = ot.Sample.ImportFromTextFile(fname, ";", 0, ",")
print("aSample from fr_FR.utf-8 file=", repr(aSample))

# export in fr too
aSample.exportToCSVFile(fname, ";", ",")
with open(fname, "r") as f:
    print("export fr=", f.readlines()[1])
os.remove(fname)