From a303f390117fcd6bd60cfc9c6cfd4ffba0756e75 Mon Sep 17 00:00:00 2001 From: Andreas Schenk Date: Wed, 23 Oct 2024 11:00:28 +0200 Subject: [PATCH] fixed issue in parser when trying to parse empty loop blocks --- src/starfile/parser.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/starfile/parser.py b/src/starfile/parser.py index 0febed0..6b905c1 100644 --- a/src/starfile/parser.py +++ b/src/starfile/parser.py @@ -116,9 +116,10 @@ def _parse_loop_block(self) -> pd.DataFrame: loop_data += '\n' # put string data into a dataframe - if loop_data == '\n': + if loop_data.startswith('\n'): n_cols = len(loop_column_names) df = pd.DataFrame(np.zeros(shape=(0, n_cols))) + df.columns = loop_column_names else: column_name_to_index = {col: idx for idx, col in enumerate(loop_column_names)} df = pd.read_csv(