We demonstrate a novel method for compressing and expanding microscopic one-dimensional monolayers consisting of a finite number of aligned magnetic dipoles using a pair of microscopic magnetic barriers. By measuring the interaction between the beads and the barriers, we are able to determine the pressure of the dipolar monolayers. Our sensor can measure one-dimensional pressure in the femto and piconewton regime and is used to probe both homogeneous and mixed monolayers consisting of magnetic beads with diameters 1.0 microm and 2.8 microm. The larger beads appear to be well-described by a formalism taking into account magnetic dipolar interactions, whereas for smaller beads, such a simple picture does not hold. Upon compressing the monolayer above a certain density, it forms a bilayer. This process is governed by steric interactions or dipolar interactions, depending on the applied magnetic field. We also found odd-even effects, where the number of beads in the monolayer determines the initial structure of the bilayer.