I used psutil and resource library and print the output to a file,
the output of the text file given below:
before argument parser:
svmem(total=13653602304, available=12436942848, percent=8.9, used=916492288, free=8878428160, active=1242267648, inactive=3044110336, buffers=85274624, cached=3773407232, shared=36450304, slab=231096320)
resource.struct_rusage(ru_utime=2.053535, ru_stime=0.378084, ru_maxrss=362036, ru_ixrss=0, ru_idrss=0, ru_isrss=0, ru_minflt=49977, ru_majflt=813, ru_nswap=0, ru_inblock=215944, ru_oublock=752, ru_msgsnd=0, ru_msgrcv=0, ru_nsignals=0, ru_nvcsw=1610, ru_nivcsw=216)`
after argument parser:
svmem(total=13653602304, available=12436942848, percent=8.9, used=916492288, free=8878428160, active=1242267648, inactive=3044110336, buffers=85274624, cached=3773407232, shared=36450304, slab=231096320)
resource.struct_rusage(ru_utime=2.054735, ru_stime=0.378084, ru_maxrss=362036, ru_ixrss=0, ru_idrss=0, ru_isrss=0, ru_minflt=49977, ru_majflt=813, ru_nswap=0, ru_inblock=215944, ru_oublock=752, ru_msgsnd=0, ru_msgrcv=0, ru_nsignals=0, ru_nvcsw=1610, ru_nivcsw=216)
after grabing the paths:
svmem(total=13653602304, available=12423421952, percent=9.0, used=930283520, free=8858972160, active=1260138496, inactive=3047149568, buffers=85520384, cached=3778826240, shared=36450304, slab=231239680)
resource.struct_rusage(ru_utime=2.062864, ru_stime=0.381083, ru_maxrss=362296, ru_ixrss=0, ru_idrss=0, ru_isrss=0, ru_minflt=50058, ru_majflt=813, ru_nswap=0, ru_inblock=215944, ru_oublock=752, ru_msgsnd=0, ru_msgrcv=0, ru_nsignals=0, ru_nvcsw=1831, ru_nivcsw=217)
i want to get the number only and print it to a csv file like this:
total,available,percent,used,free,active,inactive,buffers,cached,shared,slab,ru_utime, ru_stime,ru_maxrss,ru_ixrss,ru_idrss,ru_isrss,ru_minflt,ru_majflt,ru_nswap,ru_inblock, ru_oublock,ru_msgsnd,ru_msgrcv,ru_nsignals,ru_nvcsw,ru_nivcsw 13653602304,12423421952,9.0,930283520,8858972160,1260138496,3047149568,85520384,3778826240, 36450304,231239680,2.062864,0.381083,362296,0,0,0,50058,813,0,215944,752,0,0,0,1831,217
i know it's using regex but my knowledge of regex is limited, how do i accomplish such a feat? thanks before