0

I have a csv file which looks like this

time,a1,a2,a3,a4,a5
0,0.0598729227761,0.0598729227761,0.0,-0.0598729227761
1,0.0598729227761,0.0598729227761,0.0,-0.0598729227761
2,0.0,-0.0598729227761,0.0,-0.0598729227761
3,0.0,-0.0598729227761,0.0,-0.0598729227761
4,0.0,-0.0598729227761,0.0,-0.0598729227761
5,0.0,-0.0598729227761,0.0,-0.0598729227761
6,0.0,-0.0598729227761,0.0,-0.0598729227761
7,0.0,-0.0598729227761,0.0,-0.0598729227761
8,0.0,-0.0598729227761,0.0,-0.0598729227761
9,0.0,-0.0598729227761,0.0,-0.0598729227761
10,0.0,-0.0598729227761,0.0,-0.0598729227761
11,0.0,-0.0598729227761,0.0,-0.0598729227761
12,0.0,0.179618768328,-0.0598729227761,-0.0598729227761
13,0.0,0.179618768328,-0.0598729227761,-0.0598729227761
14,0.0,0.179618768328,-0.0598729227761,-0.0598729227761
15,0.0,0.179618768328,-0.0598729227761,-0.0598729227761
16,0.0,0.179618768328,-0.0598729227761,-0.0598729227761
17,0.0,0.179618768328,-0.0598729227761,-0.0598729227761
18,0.0,0.179618768328,-0.0598729227761,-0.0598729227761
19,0.0,0.179618768328,-0.0598729227761,-0.0598729227761
20,0.0,0.179618768328,-0.0598729227761,-0.0598729227761
21,-0.119745845552,0.0,-0.0598729227761,-0.0598729227761
22,-0.119745845552,0.0,-0.0598729227761,-0.0598729227761
23,-0.119745845552,0.0,-0.0598729227761,-0.0598729227761
24,-0.119745845552,0.0,-0.0598729227761,-0.0598729227761
25,-0.119745845552,0.0,-0.0598729227761,-0.0598729227761
26,-0.119745845552,0.0,-0.0598729227761,-0.0598729227761
27,-0.119745845552,0.0,-0.0598729227761,-0.0598729227761
28,-0.119745845552,0.0,-0.0598729227761,-0.0598729227761
29,-0.119745845552,0.0,-0.0598729227761,-0.0598729227761
30,-0.119745845552,0.0598729227761,-0.0598729227761,-0.0598729227761
31,-0.119745845552,0.0598729227761,-0.0598729227761,-0.0598729227761
32,-0.119745845552,0.0598729227761,-0.0598729227761,-0.0598729227761
33,-0.119745845552,0.0598729227761,-0.0598729227761,-0.0598729227761
34,-0.119745845552,0.0598729227761,-0.0598729227761,-0.0598729227761
35,-0.119745845552,0.0598729227761,-0.0598729227761,-0.0598729227761
36,-0.119745845552,0.0598729227761,-0.0598729227761,-0.0598729227761
37,-0.119745845552,0.0598729227761,-0.0598729227761,-0.0598729227761
38,-0.119745845552,0.0598729227761,-0.0598729227761,-0.0598729227761
39,-0.119745845552,0.0598729227761,-0.0598729227761,-0.0598729227761
40,-0.0598729227761,0.0,0.0,-0.0598729227761
41,-0.0598729227761,0.0,0.0,-0.0598729227761
42,-0.0598729227761,0.0,0.0,-0.0598729227761
43,-0.0598729227761,0.0,0.0,-0.0598729227761
44,-0.0598729227761,0.0,0.0,-0.0598729227761
45,-0.0598729227761,0.0,0.0,-0.0598729227761
46,-0.0598729227761,0.0,0.0,-0.0598729227761
47,-0.0598729227761,0.0,0.0,-0.0598729227761
48,-0.0598729227761,0.0,0.0,-0.0598729227761
49,-0.0598729227761,0.0,0.0,-0.0598729227761
50,-0.0598729227761,0.0,0.0,-0.0598729227761
51,-0.0598729227761,0.0,0.0,-0.0598729227761
52,-0.0598729227761,0.0,0.0,-0.0598729227761
53,-0.0598729227761,0.0,0.0,-0.0598729227761
54,-0.0598729227761,0.0,0.0,-0.0598729227761
55,-0.0598729227761,0.0,0.0,-0.0598729227761
56,-0.0598729227761,0.0,0.0,-0.0598729227761
57,-0.0598729227761,0.0,0.0,-0.0598729227761
58,-0.0598729227761,0.0,-0.0598729227761,-0.0598729227761
59,-0.0598729227761,0.0,-0.0598729227761,-0.0598729227761
60,-0.0598729227761,0.0,-0.0598729227761,-0.0598729227761
61,-0.0598729227761,0.0,-0.0598729227761,-0.0598729227761
62,-0.0598729227761,0.0,-0.0598729227761,-0.0598729227761
63,-0.0598729227761,0.0,-0.0598729227761,-0.0598729227761
64,-0.0598729227761,0.0,-0.0598729227761,-0.0598729227761
65,-0.0598729227761,0.0,-0.0598729227761,-0.0598729227761
66,-0.0598729227761,0.0,-0.0598729227761,-0.0598729227761
67,-0.0598729227761,0.0,-0.0598729227761,-0.0598729227761
68,0.0,-0.0598729227761,0.0,-0.0598729227761
69,0.0,-0.0598729227761,0.0,-0.0598729227761
70,0.0,-0.0598729227761,0.0,-0.0598729227761
71,0.0,-0.0598729227761,0.0,-0.0598729227761
72,0.0,-0.0598729227761,0.0,-0.0598729227761
73,0.0,-0.0598729227761,0.0,-0.0598729227761
74,0.0,-0.0598729227761,0.0,-0.0598729227761
75,0.0,-0.0598729227761,0.0,-0.0598729227761
76,0.0,-0.0598729227761,0.0,-0.0598729227761
77,0.0598729227761,0.0,-0.0598729227761,-0.0598729227761
78,0.0598729227761,0.0,-0.0598729227761,-0.0598729227761
79,0.0598729227761,0.0,-0.0598729227761,-0.0598729227761
80,0.0598729227761,0.0,-0.0598729227761,-0.0598729227761
81,0.0598729227761,0.0,-0.0598729227761,-0.0598729227761
82,0.0598729227761,0.0,-0.0598729227761,-0.0598729227761
83,0.0598729227761,0.0,-0.0598729227761,-0.0598729227761
84,0.0598729227761,0.0,-0.0598729227761,-0.0598729227761
85,0.0598729227761,0.0,-0.0598729227761,-0.0598729227761
86,0.0598729227761,0.0,-0.0598729227761,-0.0598729227761
87,-0.0598729227761,0.0598729227761,0.0,-0.0598729227761
88,-0.0598729227761,0.0598729227761,0.0,-0.0598729227761
89,-0.0598729227761,0.0598729227761,0.0,-0.0598729227761
90,-0.0598729227761,0.0598729227761,0.0,-0.0598729227761
91,-0.0598729227761,0.0598729227761,0.0,-0.0598729227761
92,-0.0598729227761,0.0598729227761,0.0,-0.0598729227761
93,-0.0598729227761,0.0598729227761,0.0,-0.0598729227761
94,-0.0598729227761,0.0598729227761,0.0,-0.0598729227761
95,-0.0598729227761,0.0598729227761,0.0,-0.0598729227761
96,0.0598729227761,-0.0598729227761,0.0598729227762,-0.0598729227761
97,0.0598729227761,-0.0598729227761,0.0598729227762,-0.0598729227761
98,0.0598729227761,-0.0598729227761,0.0598729227762,-0.0598729227761
99,0.0598729227761,-0.0598729227761,0.0598729227762,-0.0598729227761
100,0.0598729227761,-0.0598729227761,0.0598729227762,-0.0598729227761
101,0.0598729227761,-0.0598729227761,0.0598729227762,-0.0598729227761
102,0.0598729227761,-0.0598729227761,0.0598729227762,-0.0598729227761
103,0.0598729227761,-0.0598729227761,0.0598729227762,-0.0598729227761
104,0.0598729227761,-0.0598729227761,0.0598729227762,-0.0598729227761

the data is read using

acc = mlab.csv2rec('filename.csv')

and plotted like this

plt.plot((acc.time)/100.00,acc.a1,label='A1')

i wish to take only the unique values and then plot it. Is it possible to import a row only if it is different from the current row. and then use the data to plot.

ukg
  • 11
  • 2

1 Answers1

0

There's the python set type, where you can only have one copy of each value; if you don't care about the row number, just drop it from your rows, and feed the rows into a set.

If you need the row number, you can go a different route: generate a tuple from the values in your row, and use that tuple as the key in a dictionary, using the row number as value.

Marcus Müller
  • 34,677
  • 4
  • 53
  • 94