First draft of script... written on Mac and untested in ArcGIS... csv function work