I have the following file named OpenSimStats.txt:
TestreportsRootAgentCount=0agent(s)
TestreportsChildAgentCount=0childagent(s)
TestreportsGCReportedMemory=10MB(Global)
TestreportsTotalObjectsCount=0Object(s)
TestreportsTotalPhysicsFrameTime=0ms
TestreportsPhysicsUpdateFrameTime=0ms
TestreportsPrivateWorkingSetMemory=2144MB(Global)
TestreportsTotalThreads=0Thread(s)(Global)
TestreportsTotalFrameTime=89ms
TestreportsTotalEventFrameTime=0ms
TestreportsLandFrameTime=0ms
TestreportsLastCompletedFrameAt=25msago
TestreportsTimeDilationMonitor=1
TestreportsSimFPSMonitor=55.3333320617676
TestreportsPhysicsFPSMonitor=55.4766654968262
TestreportsAgentUpdatesPerSecondMonitor=0persecond
TestreportsActiveObjectCountMonitor=0
TestreportsActiveScriptsMonitor=0
TestreportsScriptEventsPerSecondMonitor=0persecond
TestreportsInPacketsPerSecondMonitor=0persecond
TestreportsOutPacketsPerSecondMonitor=0persecond
TestreportsUnackedBytesMonitor=0
TestreportsPendingDownloadsMonitor=0
TestreportsPendingUploadsMonitor=0
TestreportsTotalFrameTimeMonitor=18.18239402771ms
TestreportsNetFrameTimeMonitor=0ms
TestreportsPhysicsFrameTimeMonitor=0.0106373848393559ms
TestreportsSimulationFrameTimeMonitor=0.17440040409565ms
TestreportsAgentFrameTimeMonitor=0ms
TestreportsImagesFrameTimeMonitor=0ms
TestreportsSpareFrameTimeMonitor=18.1818199157715ms
TestreportsLastReportedObjectUpdates=0
TestreportsSlowFrames=1
I want to transform this file into a CSV file like the following:
TestreportsRootAgentCount,TestreportsChildAgentCount,...,TestreportsSlowFrames
0,0,10,0,0...,1
By which I mean:
- take out all words before and after a delimiter in this case the delimeter is "="
- Put all words on the left of the delimeter in one line separated by commas
- Insert a new line at the end
- Then put whatever after the delimiter (
=
) – the numbers only (without the units or characters after the numbers) in another line where these numbers are separated by commas. - Then insert a new line
Any ideas/suggestions on how this can be done in Linux shell scripting? By using sed or gawk?
Best Answer
The 9 paths to OpenSim enlightenment:
With
sed
and some shell magic:With
sed
, without shell magic:With shell magic and a tiny bit of
sed
:With
cut
and some shell magic:With GNU
datamash
:With
perl
:With
grep
:With
bash
:With
awk
:Bonus 10th path for data nerds, with
csvtk
:Bonus 11th path with
vim
: