Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to eliminate nothing elements in a array (1D) in Julia?

Tags:

julia

I would like to know how I could eliminate nothing elements in a Julia array (1D) like the one below. It was built from reading a text file with lines with no relevant information mixed with lines with relevant information. "nothing" is type Void and I would like to clean the array of all of it.

nothing                                                                                                                                 
nothing                                                                                                                                 
nothing                                                                                                                                 
nothing                                                                                                                                 
nothing                                                                                                                                 
"   -16.3651\t     0.1678\t    -4.6997\t   -14.0152\t    -2.6855\t   -16.0294\t    -7.8049\t   -27.1912\t    -5.0354\t   -14.5187\t\r\n"
"   -16.4490\t    -1.0910\t    -3.6087\t   -12.6724\t    -1.5945\t   -14.7705\t    -7.2174\t   -25.2609\t    -3.7766\t   -14.3509\t\r\n"
"   -16.4490\t    -2.2659\t    -2.4338\t   -10.9100\t    -0.5875\t   -13.6795\t    -6.7139\t   -22.9950\t    -2.9373\t   -14.0991\t\r\n"
like image 515
RgrNormand Avatar asked Dec 10 '22 20:12

RgrNormand


1 Answers

testvector[testvector.!=nothing] is also a very readable option.

benchmarking can help choose the most efficient code.

like image 136
Dan Getz Avatar answered Dec 13 '22 09:12

Dan Getz