Can I easily export active Membership user data to a CSV file

Hi there,

I'm trying to determine the best way to create a CSV file with member data (a partner organization isn't able to modify their system to work with WP). Members data exported must include standard name/contact data (in wp_usermeta), plus the Membership level, and only export records matching current city (that's also saved in wp_usermeta).

I know this is may be a complex request from a shortcode/hook perspective, and with PHP I know there's a bunch of work to do, but at least I know how to do this all in PHP (queries, etc.). If I can save myself some time doing it using some pre-existing functions, I'd rather know than find out later!