TransWikia.com

Remove errors from sublists after Excel import

Mathematica Asked on May 16, 2021

I have a very long list such as:

https://pastebin.com/9vYDLsVp

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

Thanks

EDIT

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}]]

One Answer

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:

data=ToExpression[Import["https://pastebin.com/raw/rSVRyTge"]];

you can remove them whether by exact pattern

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

or some generalization

DeleteCases[data,{___,_String,___},Infinity]

Correct answer by Vitaliy Kaurov on May 16, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP