Skip to content

Commit

Permalink
fix: update search pattern to find new lines in cells
Browse files Browse the repository at this point in the history
  • Loading branch information
oyurekten committed Nov 20, 2024
1 parent 1d68f25 commit bcf703a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions metabolights_utils/isatab/default/parser/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,16 +168,14 @@ def read_table_file(
)
)
file_content = re.sub(r"[\r\n][\r\n]+", r"\n", file_content)

find_matches = re.findall(r'\t"([^\t]*)([\r\n]+)([^\t]*)"\t', file_content)
pattern = r'(^|\t)"([^"\t]*)([\r\n]+)([^"\t]*)"(\t|\n\|\r|$)'
find_matches = re.findall(pattern, file_content)

if find_matches:
max_iteration = 10
iteration = 0
while True:
new_file_content = re.sub(
r'\t"([^\t]*)([\r\n]+)([^\t]*)"\t', r'\t"\1\3"\t', file_content
)
new_file_content = re.sub(pattern, r'\1"\2\4"\5', file_content)
if new_file_content == file_content:
break
if iteration < 1:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def fix_isa_table_file(
iteration = 0
while True:
new_file_content = re.sub(
new_line_in_cells_pattern, r'\t"\2\4"\t', file_content
new_line_in_cells_pattern, r'\1"\2\4"\5', file_content
)
if new_file_content == file_content:
break
Expand Down

0 comments on commit bcf703a

Please sign in to comment.