How important is it for each row of data to have the same number of features? I'm using decision tree learning to try and classify a device based its components. Different devices have a different number of components and the location of these components within the device is important.

Device 1 might have components 9, 3, 8, 4, and 1 in that order.
Then device 2 might have components 4, 3, 2, 6, and 7 in that order. 

The issue with this is I'm finding it difficult to convert these into features.

I would have the features of each row be the locations and the value be the name of the component in that location but with some devices having few (&lt;10) components and some with many more (>60) this could lead to many blank values.

I'm worried that when training if most of the training data is on devices with for example &lt; 40 components, when trying to classify a device with > 40 components I'm assuming it would go terribly wrong, but you also can't just use devices with more than 40 components because then it will never learn to work for simple devices with smaller numbers of components.

If there is a technique or way to get around this please let me know! Or if I've come at this problem the wrong way and need to rethink let me know that as well!
A lot of blank values in row isn't a problem, you can use sparse matrices. 

I suppose you have a dataset to work with. So you can use validation and check some your suspicions. For example: fit model using dataset with &lt;40 components and test it on another part of data. 

Trying to consider order of components within device is challenging task. Maybe you can add pairs of components as features... 

This is just my suggestions, I'm not an experienced data scientist =)