From 609f13585512f008bd2c1c39ed06acbde2ae904c Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Wed, 19 Jul 2023 19:09:42 +0200 Subject: [PATCH] correcter preview for text files with mixed delimiters --- src/nmreval/io/asciireader.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/nmreval/io/asciireader.py b/src/nmreval/io/asciireader.py index f8232b1..dddf87d 100644 --- a/src/nmreval/io/asciireader.py +++ b/src/nmreval/io/asciireader.py @@ -15,7 +15,7 @@ NUMBERRE = re.compile(r'[0-9]\.*[0-9]*[Ee]*[+-]*[0-9]*') class AsciiReader: - delimiters = ['\t', ' ', ','] + # delimiters = ['\t', ' ', ','] def __init__(self, fname): self.fname = None @@ -49,7 +49,8 @@ class AsciiReader: with self.fname.open('r') as f: for i, line in enumerate(islice(f, len(self.header)+len(self.lines), num_lines)): line = line.rstrip('\n\t\r, ') - line = re.split(r'[\s,;]', line) + line = re.sub(r'[\t ;,] *', ';', line) + line = line.split(';') try: comment_start = line.index('#')