Group Abstract Group Abstract

Message Boards Message Boards

0
|
8.7K Views
|
7 Replies
|
2 Total Likes
View groups...
Share
Share this post:

How to remove lists in list containing a variable string pattern DropCases

Posted 10 years ago
POSTED BY: David Proffer
7 Replies

Rather than using StringMatchQ one could use the nicer StringContainsQ or even StringStartsQ. These are slight variations of StringMatchQ...

POSTED BY: Sander Huisman
Posted 10 years ago
POSTED BY: Dana DeLouis
Posted 10 years ago
POSTED BY: Girish Arabale
Posted 10 years ago
POSTED BY: Dana DeLouis
Posted 10 years ago

With the PatternTest-

DeleteCases[z1, {_?(StringMatchQ[#, "TOTAL*"] &), __}, Infinity]
POSTED BY: Girish Arabale

You can try with

DeleteCases[tmp3, 
 str_String /; StringMatchQ[str, "TOTAL " ~~ DigitCharacter ..], 2]
POSTED BY: Gianluca Gorni
Posted 10 years ago

Thank you Gianluca! That looks to be the solution! Molte grazie!

z1 = {{"January 2015", "9,552.0", "38,158.4", 
   "-28,606.4"}, {"February 2015", "8,699.8", "31,240.1", 
   "-22,540.3"}, {"March 2015", "9,887.2", "41,121.9", 
   "-31,234.7"}, {"April 2015", "9,316.8", "35,795.1", 
   "-26,478.3"}, {"May 2015", "8,758.8", "39,211.2", 
   "-30,452.4"}, {"June 2015", "9,687.8", "41,145.1", 
   "-31,457.3"}, {"July 2015", "9,500.7", "41,077.2", 
   "-31,576.6"}, **{"TOTAL 2015", "65,403.1", "267,749.0", 
   "-202,345.9"}**, {"January 2014", "10,266.1", "38,278.6", 
   "-28,012.5"}, {"February 2014", "9,766.4", "30,617.1", 
   "-20,850.7"}, {"March 2014", "10,922.0", "31,325.9", 
   "-20,404.0"}, {"April 2014", "9,027.2", "36,327.6", "-27,300.4"}}

z2 = DeleteCases[
  z1, {str_String /; 
    StringMatchQ[str, "TOTAL " ~~ DigitCharacter ..], __}, 2]

{{"January 2015", "9,552.0", "38,158.4", 
  "-28,606.4"}, {"February 2015", "8,699.8", "31,240.1", 
  "-22,540.3"}, {"March 2015", "9,887.2", "41,121.9", 
  "-31,234.7"}, {"April 2015", "9,316.8", "35,795.1", 
  "-26,478.3"}, {"May 2015", "8,758.8", "39,211.2", 
  "-30,452.4"}, {"June 2015", "9,687.8", "41,145.1", 
  "-31,457.3"}, {"July 2015", "9,500.7", "41,077.2", 
  "-31,576.6"}, {"January 2014", "10,266.1", "38,278.6", 
  "-28,012.5"}, {"February 2014", "9,766.4", "30,617.1", 
  "-20,850.7"}, {"March 2014", "10,922.0", "31,325.9", 
  "-20,404.0"}, {"April 2014", "9,027.2", "36,327.6", "-27,300.4"}}
POSTED BY: David Proffer
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard