Extraction script to convert data to csv