Now that Create: Steam 'n' Rails allows you to automatically (dis)assemble trains by using a deployer holding a wrench (insert with a hopper), you should probably use that mod instead!
Before Create 0.5 trains, we had the minecart contraption. These guys could be automatically (dis)assembled, allowing you to do really cool things like unloading them by physically moving cargo off the back of it. But with the new trains, our only option is the boring Portable Storage Interface.
This datapack allows you to create train stations with special behaviour that can load and unload minecart contraptions onto your trains, giving back those possibilities! You can dynamically swap out what cargo a train is carrying, or otherwise perform any tasks which require disassembling part of your train.
Video with full bells and whistles Video with pure functionality
The system is very simple to set up. All you need to do is place the train station block directly next to the tracks, where you want your cargo minecart to be. Then place a comparator coming from the train station, away from the tracks, and place an armor stand on top of the comparator while you are facing towards the tracks (the direction is important!). This should make a ding and place a redstone lamp, and you're done!
When a train pulls into the station, the unloading station will automatically attempt to unload any cargo. When you want to load the train up and send it off, simply send a redstone pulse to the lamp. After loading, the station will be automatically pulsed, so you can configure your train schedule to leave on that criteria.
A suggested way to load the system with cargo is to let the train pull into the station before placing a minecart assembler on a block directly above where you want to cargo minecart to fall onto the train. Then assemble your custom cargo, break the block, and send the train on its way.
To remove the unloading station, simply break the armor stand. Don't break the redstone lamp or the comparator, as this will cause the unloading station to stop working. The only other thing to worry about is making sure there's a solid block for the minecart to sit on, which should be behind the redstone lamp (a cobblestone block will automatically be placed there if there isn't).
If the train is driving quickly, it is possible for loaded minecart cargo to come loose and fall from the train. To prevent this, simply limit the train's max speed to ~15% in the schedule, which appears reliable. On one hand this is a drawback, but it is also kind of neat how this creates a distinction between slow and steady cargo trains and speedy passenger trains - and gives the player an incentive to specifically build the latter instead of just hitching a ride on their freight trains!
This can also happen on inclined tracks. Not to worry if the cargo does come loose though, as the system is smart enough that trains remember the last cart that was loaded onto them, and will teleport it back if they arrive at the next station and it's missing.
Suggestions for use:
You can add a pulse repeater between the comparator and the redstone block to very simply add a timed delay from unloading before automatically loading back onto the train.
If you pull redstone off the comparator and use a couple of pulse repeaters, you can sync up some extra aesthetics to simulate a crane actually moving the cargo, instead of it floating by magic.
Note to pack devs:
The stations place a free redstone lamp, spruce button, and cobblestone block. Consider e.g. ensuring that the redstone block cannot be processed into anything, to remove any potential exploits.