Skip to content
Snippets Groups Projects
Commit 32eb1b77 authored by Marko Mecina's avatar Marko Mecina
Browse files

replace newlines with semicolon in csv export

parent c99d4937
Branches
No related tags found
No related merge requests found
...@@ -14,21 +14,23 @@ def run(jfile, outfile): ...@@ -14,21 +14,23 @@ def run(jfile, outfile):
data = json.loads(jfile) data = json.loads(jfile)
header = 'Item|Description|Verification|TestResult' header = 'Item|Description|Verification|TestResult'
name = '{}|{}|Test spec. version: {}| IASW-{}'.format(data['_name'], data['_description'], data['_spec_version'], data['_iasw_version']) name = '{}|{}|Test spec. version: {}| IASW-{}'.format(data['_name'], replace_newline(data['_description']),
data['_spec_version'], data['_iasw_version'])
# Date from last time the json file was changed + current date # Date from last time the json file was changed + current date
date = 'Date||{}|'.format(datetime.datetime.now().strftime('%Y-%m-%d')) date = 'Date||{}|'.format(datetime.datetime.now().strftime('%Y-%m-%d'))
testcomment = 'Comment|{}||'.format(data['_comment']) testcomment = 'Comment|{}||'.format(replace_newline(data['_comment']))
precond = 'Precond.|{}||'.format(data['_precon_descr']) precond = 'Precond.|{}||'.format(replace_newline(data['_precon_descr']))
postcond = 'Postcond.|{}||'.format(data['_postcon_descr']) postcond = 'Postcond.|{}||'.format(replace_newline(data['_postcon_descr']))
steps = [] steps = []
for step in data['sequences'][0]['steps']: for step in data['sequences'][0]['steps']:
line = 'Step {}|{}|{}|'.format(step['_step_number'], step['_description'], step['_verification_description']) line = 'Step {}|{}|{}|'.format(step['_step_number'], replace_newline(step['_description']),
replace_newline(step['_verification_description']))
steps.append(line) steps.append(line)
if step['_step_comment'] != '': if step['_step_comment'] != '':
comment = 'Comment|{}||'.format(step['_step_comment']) comment = 'Comment|{}||'.format(replace_newline(step['_step_comment']))
steps.append(comment) steps.append(comment)
if outfile[-1] == '/': # If only path is given but no filename if outfile[-1] == '/': # If only path is given but no filename
...@@ -43,6 +45,10 @@ def run(jfile, outfile): ...@@ -43,6 +45,10 @@ def run(jfile, outfile):
fd.write(buf) fd.write(buf)
def replace_newline(txt):
return txt.replace('\n', '; ')
if __name__ == '__main__': if __name__ == '__main__':
json_file_path = sys.argv[1] json_file_path = sys.argv[1]
...@@ -50,6 +56,5 @@ if __name__ == '__main__': ...@@ -50,6 +56,5 @@ if __name__ == '__main__':
outputfile = sys.argv[2] outputfile = sys.argv[2]
else: # If no filename is given take the working directory path, filename is used from the json file else: # If no filename is given take the working directory path, filename is used from the json file
outputfile = os.getcwd() + '/' outputfile = os.getcwd() + '/'
# outputfile = '/'.join(json_file_path[:-len(json_file_path.split('/')[-1])-1]) + '/' # This would take the json File path
run(json_file_path, outputfile) run(json_file_path, outputfile)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment