0

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

kglr
  • 394,356
  • 18
  • 477
  • 896
Phadreus
  • 461
  • 2
  • 10

3 Answers3

2
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"} *)
kglr
  • 394,356
  • 18
  • 477
  • 896
1

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

instruments = DeleteCases[indexMaster, _Missing]
{"^RDM-SO", "AMEX"}
Karsten7
  • 27,448
  • 5
  • 73
  • 134
1

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

DeleteCases[indexMaster,Missing["NotAvailable"]]
(* {"^RDM-SO", "AMEX"} *)
Jinxed
  • 3,753
  • 10
  • 24