CoCalc Public Filesconvert_to_md_table_format.ipynbOpen with one click!
Author: Tim Clemans
Views : 51
Compute Environment: Ubuntu 18.04 (Deprecated)
In [4]:
s = """date,go_num,badge_num,initial_call_type,final_call_type,how_received 2017-07-22,2017-267536,5836,NARC,188,Onview 2017-07-22,2017-267600,5790,NARC,Narcotics Other,Onview 2017-07-22,2017-267672,7732,DOWN1,Mischief or Nuisance Mischief or Nuisance,Onview 2017-07-22,2017-267780,7515,CRISIS,Mental Complaint Mental Complaint,Onview"""
In [5]:
s = s.split('\n') new_format = '' new_format += '|' + '|'.join(s[0].split(',')) + '|\n' new_format += '|' + '|'.join(['-'*len(c) for c in s[0].split(',')]) + '|\n' for line in s[1:]: new_format += '|' + '|'.join(line.split(',')) + '|\n'
In [6]:
print new_format
|date|go_num|badge_num|initial_call_type|final_call_type|how_received| |----|------|---------|-----------------|---------------|------------| |2017-07-22|2017-267536|5836|NARC|188|Onview| |2017-07-22|2017-267600|5790|NARC|Narcotics Other|Onview| |2017-07-22|2017-267672|7732|DOWN1|Mischief or Nuisance Mischief or Nuisance|Onview| |2017-07-22|2017-267780|7515|CRISIS|Mental Complaint Mental Complaint|Onview|
In [ ]: