Skip to content

Commit

Permalink
using python for removal of empty lines because it did not work
Browse files Browse the repository at this point in the history
  • Loading branch information
jindrahelcl committed Nov 26, 2023
1 parent c13aed6 commit 5d81f7a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
4 changes: 2 additions & 2 deletions opuscleaner/filters/remove_empty_lines.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"description": "Remove lines that are empty or just whitespace on either side",
"type": "bilingual",
"command": "grep -avE $'^\\\\s*\\t|\\t\\\\s*$|^[^\\t]*$'",
"command": "./remove_empty_lines.py",
"parameters": {}
}
}
16 changes: 16 additions & 0 deletions opuscleaner/filters/remove_empty_lines.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env python3
import sys

def main():
for line in sys.stdin:
fields = line.strip("\r\n").split("\t")
ok = True
for field in fields:
if not field.strip():
ok = False
break
if ok:
sys.stdout.write(line)

if __name__ == '__main__':
main()

0 comments on commit 5d81f7a

Please sign in to comment.