For the year 2016 there have been not so many sufficient records so I want to delete all entries from year 2016. Which means in the excel file I want to get rid of all rows where the first column has the value 2016.
OriginalData =
Import[FileNameJoin[{NotebookDirectory[], "suicide.xlsx"}]][[1]];
Export[FileNameJoin[{NotebookDirectory[], "suicide.mx"}], OriginalData]
suicide2 =
Import[FileNameJoin[{NotebookDirectory[],
"suicide.mx"}]];
suicide = Drop[suicide2[All], "2016"] (*With this command I intended to remove the lines from the data "suicide2", but it did not work.*)
Could you please let me know how to remove all entries from the year 2016? I have attached the xlsx file.
I recommend using {"Data", 1} to select the first sheet as it is more efficient than taking the first part after importing everything. Then, you want to select each row where the second position is not 2016 (its a number, not a string).
thank you very much for your response. I tried your command but it did not work and I can not really recall what it should execute. I wish to delete all rows where the value is 2016 in column 2.
Change Drop[suicide2[All], "2016"] to Select[suicide2, #[[2]] != 2016 &] or DeleteCases[suicide2, {x_, 2016., y___}] like Hans suggested. Both will do the same thing from a different perspective.