From dcb47d6e27b45638ef1a22411af64487041df56e 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 @@ def read_elk_file2(self, filename, to_replace): 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): """