HI! I need help putting the output from terminal in a csv file. I work on linux and I have python 2.7.15. I am running a python program which also runs some shell scripts.
I need to capture the output from the .sh scripts and put it nicely in a csv table. I am using "commands.getoutput('bash example.sh')" to capture the output of the scripts (I can use subprocess too if needed). The outputs looks something like this: In case of an error { "error" : { "body" : "The requested device is currently not online. "detail" : "Make sure to connect the device", "event" : 123456, "header" : "Device Unavailable (123456)" } } And in case of a good output it look similar but has "status :0" instead of event and ofc it does say that it passed the test. I need to export the results of the .sh tests in a csv file with my .py program. The boss expects a table with 3 columns. The first one with The title TEST which has the name of the tests (.sh scripts). The 2nd with PASS/FAIL (this is determined by the "status" : 0 output for some tests and with a number between 1 and 4000 for others (i used regex for this, but I struggle a bit here too) and the 3rd one which returns the Value ( 0 in case status is 0 or the number between 1 and 4000 for the other tests). I really need some ideas, I struggle for 3 days already using regex, commands, subprocess and watching tutorials. I just can't solve this yet, I really need some ideas. Much appreciated. -- https://mail.python.org/mailman/listinfo/python-list