I have a very long list such as:


At the end of each sublist for some reason I have {,-6}. How can I remove that from each sublist of the list?



The list is generated getting data from an Excel file and for some reason at the end it gives me {,-6} using:

Extract[Import["file.xlsx"], 1][[3 ;; All, {i, i + 1}]]
  • 2
    $\begingroup$ Most/@list or list[[All, ;;-2]]? $\endgroup$
    – kglr
    Commented Jan 13, 2021 at 4:58
  • 2
    $\begingroup$ Most/@First[Import["file.xlsx"]] or Import["file.xlsx"][[1,All,;;-2]]] $\endgroup$
    – kglr
    Commented Jan 13, 2021 at 5:00
  • $\begingroup$ Thank you! It works ! $\endgroup$
    – John
    Commented Jan 13, 2021 at 5:04
  • $\begingroup$ @kglr here's another list: pastebin.com/rSVRyTge . It doesn't seem to work on that one. How can I remove all the {,-6} values from that one? $\endgroup$
    – John
    Commented Jan 13, 2021 at 5:12

1 Answer 1


You seem to have a problem that Excel puts some errors containing string expressions. If they appear in random places but you know how they look you can delete them based on their pattern. After you import:


you can remove them whether by exact pattern

DeleteCases[data,{"",-6 ""},Infinity]

or some generalization


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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