Adding csv export from refdb - partially coded up