Open qgeissmann opened 8 years ago
trajectory = Trajectory([1, 2, 3, 4, 5, 6], [3, 2, 1,5, 2, 4], Moment([1], symbol='description'))
with open("my_file.csv","w") as out:
trajectory.to_csv(out)
We get a file like this:
time,value
1.000000,3.000000
2.000000,2.000000
3.000000,1.000000
4.000000,5.000000
5.000000,2.000000
6.000000,4.000000
tr1 = Trajectory([1, 2, 3, 4, 5, 6], [3, 2, 1, 5, 2, 4], Moment([1], symbol='y_1'))
tr2 = Trajectory([1, 2, 3, 4, 5, 6], [3, 2, 1, 5, 2, 4], Moment([1], symbol='y_2'))
tc = TrajectoryCollection([tr1,tr2])
with open("my_file.csv","w") as out:
tc.to_csv(out)
Output looks like that:
description,time,value
y_1,1.000000,3.000000
y_1,2.000000,2.000000
y_1,3.000000,1.000000
y_1,4.000000,5.000000
y_1,5.000000,2.000000
y_1,6.000000,4.000000
y_2,1.000000,3.000000
y_2,2.000000,2.000000
y_2,3.000000,1.000000
y_2,4.000000,5.000000
y_2,5.000000,2.000000
y_2,6.000000,4.000000
Some users will want to export trajectories and work further with other tools. For me it makes more sense to export them in a long (as opposed to wide) format. Then, the headers of a multi trajectory csv will be
name
,time
andvalue
(possibly sensitivity data can be included).