The csv output will output empty fields is the event is missing them, so all you really need is
csv { autodetect_column_names => true remove_field => [ "message" ] }
ruby { code => 'event.set(event.get("Type"), event.get("Count"))' }
The fields option on the filter is not optional, but you could use a technique similar to this to find the set of fields required.