You can import it as a CSV ? just tell it to use ‘|’ as a delimiter?
and then you can trim the input, which will get rid of the space?

import-csv "somefile.txt" -delimiter "|"

maybe I’m missing something?

1 Spice up