0
$\begingroup$

This question already has an answer here:

I have a list of stock symbols and related information containing some entries Missing["NotAvailable"]. I would like to delete all nested lists which contain a NotAvaiable entry, as Mathematica obviously does not support these instruments anymore (see also http://reference.wolfram.com/mathematica/ref/FinancialData.html).

The list entries are formated as follows:

indexMaster= {"^RDM-SO", Missing["NotAvailable"], "AMEX"}

I tried to use the following function, but it does not work.

instruments =
 DeleteCases[indexMaster, {p__, q_String, r__} /;
    StringMatchQ[q, "*NotAvailable*"] -> {p, q, r}]

Does anyone have an idea how to delete the Missing["NotAvailable"] entries?

Thanks

$\endgroup$

marked as duplicate by Sjoerd C. de Vries, bbgodfrey, Dr. belisarius, Öskå, Simon Woods Mar 9 '15 at 19:41

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2
$\begingroup$
indexMaster= {"^RDM-SO", Missing["NotAvailable"], "AMEX"}
Select[indexMaster, Internal`LiterallyAbsentQ[#, "NotAvailable"] &]
(* {"^RDM-SO", "AMEX"} *)

indexMaster2 = {"^RDM-SO", Missing["NotAvailable"], Missing[], "AMEX", "NotAvailable"};
Select[indexMaster2, Internal`LiterallyAbsentQ[#, "NotAvailable"] &]
(* {"^RDM-SO", Missing[], "AMEX"} *)

DeleteCases[indexMaster2, _?(Internal`LiterallyOccurringQ[#, "NotAvailable"] &)]
(* {"^RDM-SO", Missing[], "AMEX"} *)
$\endgroup$
1
$\begingroup$

Missing["NotAvailable"] is not a string. Its Head is Missing, therefore you can use

instruments = DeleteCases[indexMaster, _Missing]
{"^RDM-SO", "AMEX"}
$\endgroup$
1
$\begingroup$

Just use the same pattern as what you don't want to see:

DeleteCases[indexMaster,Missing["NotAvailable"]]
(* {"^RDM-SO", "AMEX"} *)
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.