Dedupe some code for CSV libraries