Skip to content

Commit

Permalink
Fix for non-ascii chars in header
Browse files Browse the repository at this point in the history
  • Loading branch information
lmperry committed Dec 19, 2018
1 parent 6ecf80f commit d712a4c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"flywheel": {
"suite": "Stanford CNI"
},
"version": "1.6.0",
"version": "1.6.1",
"custom": {
"docker-image": "stanfordcni/pfile-mr-classifier:1.6.0"
"docker-image": "stanfordcni/pfile-mr-classifier:1.6.1"
},
"config": {
"timezone": {
Expand Down
8 changes: 8 additions & 0 deletions pfile-mr-classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
logging.basicConfig()
log = logging.getLogger('pfile-mr-classifier')

def format_string(in_string):
formatted = re.sub(r'[^\x00-\x7f]',r'', str(in_string)) # Remove non-ascii characters
formatted = filter(lambda x: x in string.printable, formatted)
if len(formatted) == 1 and formatted == '?':
formatted = None
return formatted

def get_pfile_classification(pfile):
"""
Determine pfile classification from series description, etc.
Expand Down Expand Up @@ -185,6 +192,7 @@ def extract_pfile_header(pfile_header_csv):
next(csvreader)
for row in csvreader:
if row[1]:
row[1] = format_string(row[1])
try:
row[1] = int(row[1])
except:
Expand Down

0 comments on commit d712a4c

Please sign in to comment.