Search code examples
texttransformtxt

Transform a comma deliniated file


I have a text file that looks like this.

{"date":"13:57",
"temp":"32.5",
"tempTL":"23.8",
"tempTH":"32.6",
"intemp":"66.2",
"dew":"27.3",
"dewpointTL":"21.0",
"dewpointTH":"28.3",
"apptemp":"27.4",
"apptempTL":"17.5",
"apptempTH":"27.7",
"wchill":"32.5",
"wchillTL":"19.8",

I need to transforme it like this

date=13:57
temp=32.5
tempTL=23.8
tempTH=32.6
intemp=66.2
dew=27.3
dewpointTL=21.0
dewpointTH=28.3
apptemp=27.4
apptempTL=17.5
apptempTH=27.7
wchill=32.5
wchillTL=19.8

The resulting file need to be in txt and will be read by a linux script. I will be using linux to DL the file to my RPi.

Sorry I am very much a newb. not sure to try linux or python to do this.


Solution

  • Needed to use the sed-i's to find and replace.

    #replace the " with  nothing
    sed -i 's/"//g' realtimegauges.txt
    # replace the : with = sign.
    sed -i 's/:/=/g' realtimegauges.txt
    #Remove the trailing ,
    sed -i 's/,//g' realtimegauges.txt