I'm sure I've seen instructions on how do do this unfortunately it was a few months ago and have forgotten them.
Thanks in advance to anyone who answers.
Assuming you are using Synaptic Package Manager, in your text file, you structure it in the following format:
where package name e.g. gimp would be a space or tabs can be install, remove, purge
And obviously put each package on a new line. No need to include dependencies.
Then in Synaptic, go to File > Read Markings and point it to your file. What this does is mark all the changes to be made and then you can proceed as usual. I have not tried @Jo-erlend's method but it definitely sounds simpler