GnuCash has a scripting engine. If you have to do a specific correction very often, it might be worth it to implement something. If possible, the CSV should be preprocessed of course.
If nothing else works, a Gnucash file is XML. A bit annoying to work with, but quite possible.