1

I have an array that looks just like this one:

 array(['00:00;1;5950;6\r', '00:10;1;2115;6\r', '00:10;2;4130;6\r',
   '00:10;3;5675;6\r', '00:20;1;1785;6\r'], 
  dtype='|S15')

For my evaluation I need only the value after the second semicolon at each array entry. Here in this example, I need the values:

5950, 2115, 4130, 5675, 1785.

Is it possible to manipulate the array in way to get the entries I want? And how can that be solved? I know how to remove the symbols, so in the end I get the array:

['0000159506\r', '0010121156\r', '0010241306\r', '0010356756\r', '0020117856\r']

But I don't know if this is the right way to handle these problem. Do anyone know what to do? Thank you very much!

2 Answers 2

2

Try this:

A = array(['00:00;1;5950;6\r', '00:10;1;2115;6\r', '00:10;2;4130;6\r',
   '00:10;3;5675;6\r', '00:20;1;1785;6\r'], 
  dtype='|S15')
list_ = [str(x.split(";")[2]) for x in A]
Sign up to request clarification or add additional context in comments.

1 Comment

Don't get the float part. Target output is str, then why cast to float?
1

The best way to get these values is to use the python split function.

You can choose the delimiter. So in this case the delimiter can be a ;.

result = line.split(';')

and then just find the third value of the resulting list.

num = result[2]

1 Comment

Yes thank you! That was exactly what I was searching for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.