make export script resilient against bad data