write to csv flattened json with col names