From b5a314588c7b954dc7aad9665e9c86cf2b2c7753 Mon Sep 17 00:00:00 2001 From: Dan Howe Date: Thu, 19 Apr 2018 07:14:41 +1000 Subject: [PATCH] Raise error if layer is empty --- dxf_to_csv/dxf_to_csv.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dxf_to_csv/dxf_to_csv.py b/dxf_to_csv/dxf_to_csv.py index cfd77e5..978c158 100644 --- a/dxf_to_csv/dxf_to_csv.py +++ b/dxf_to_csv/dxf_to_csv.py @@ -24,10 +24,6 @@ Convert specific layer: """ -__author__ = "D. Howe" -__version__ = "0.2.0" -__email__ = "d.howe@wrl.unsw.edu.au" - import os import sys import numpy as np @@ -96,6 +92,13 @@ def convert(dxf_name, layer_name): # Add to dataframe points = pd.DataFrame(data) + # Ensure dataframe is not empty + if points.shape[0] == 0: + if layer_name: + raise ValueError('No objects found on layer {}'.format(layer_name)) + else: + raise ValueError('No objects found.') + # Check if there are z coordinates if 'z' not in points.columns: points['z'] = np.nan