From fafd625879b01091d939a69723cbfc93780222de Mon Sep 17 00:00:00 2001 From: Xiao Jiang <65940810+jiangx1994@users.noreply.github.com> Date: Wed, 4 Sep 2024 17:19:56 +0800 Subject: [PATCH] Update readElkfiles.py During the Elk conversion process, two files, SYMCRYS.OUT and LATTICE.OUT, need to be read. However, after the Elk calculation is completed, there are some blank lines in these files, which leads to recognition failure of readElkfiles.py. By using line.strip(), non-blank lines can be directly read. --- .../converters/elktools/readElkfiles.py | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/python/triqs_dft_tools/converters/elktools/readElkfiles.py b/python/triqs_dft_tools/converters/elktools/readElkfiles.py index 4fe6e0e2..584283e2 100644 --- a/python/triqs_dft_tools/converters/elktools/readElkfiles.py +++ b/python/triqs_dft_tools/converters/elktools/readElkfiles.py @@ -98,20 +98,21 @@ class readElkfiles: if not(os.path.exists(filename)): raise IOError("File %s does not exist." % filename) for line in open(filename, 'r'): - for old, new in to_replace.items(): - line = line.replace(old, new) - # removes the substring after '(' character - if it exists - if "(" in line: - line = self.split_string2(line,'(') - # removes the substring after '+' character - if it exists - if "+" in line: - line = self.split_string2(line,'+') - # removes the substring after '|' character - if it exists - if "|" in line: - line = self.split_string2(line,'|') - #only include lines which have multiple characters - if(len(line)>1): - yield line.split() + if line.strip(): + for old, new in to_replace.items(): + line = line.replace(old, new) + # removes the substring after '(' character - if it exists + if "(" in line: + line = self.split_string2(line,'(') + # removes the substring after '+' character - if it exists + if "+" in line: + line = self.split_string2(line,'+') + # removes the substring after '|' character - if it exists + if "|" in line: + line = self.split_string2(line,'|') + #only include lines which have multiple characters + if(len(line)>1): + yield line.split() def split_string(self,line): """