Rangement des données d'un fichier XML sur la même ligne avec awk
Résolu
GHISLINO
Messages postés
234
Statut
Membre
-
GHISLINO Messages postés 234 Statut Membre -
GHISLINO Messages postés 234 Statut Membre -
Bonjour à tous,
Je cherche à récupérer des informations (en gras) dans fichier XML et les ranger sur la meme ligne pour chaque entitées.
Pour obtenir un fichier final dont les éléments séparés par un point virgule comme le montre ci-dessous
Merci d'avance
Je cherche à récupérer des informations (en gras) dans fichier XML et les ranger sur la meme ligne pour chaque entitées.
CLI LOG: CLI 2.5.10-client started
CLI LOG: {
"time": "3:28:15 PM",
"requestId": 1,
"requestStatus": "completed",
"requestMessage": {
"connected": [
{
"source": {
"id": "/MRBTS-1/RAT-1/RUNTIME_VIEW-1/MRBTS_R-1/EQM_R-1/APEQM_R-1/RMOD_R-2",
"extendedId": {
"internal": "/MRBTS-1/RAT-1/RUNTIME_VIEW-1/MRBTS_R-1/EQM_R-1/APEQM_R-1/RMOD_R-2",
"configuration": "MRBTS-60001/EQM-1/APEQM-1/RMOD-1",
"runtime": "MRBTS-60001/EQM_R-1/APEQM_R-1/RMOD_R-2"
},
"productName": "FRGU",
"serialNumber": "K9170204866",
"productCode": "472956A.102",
"connector": {
"id": "/MRBTS-1/RAT-1/BTS_L-1/EQM_L-1/RMOD_L-2/CONNECTOR_L-1",
"extendedId": {
"internal": "/MRBTS-1/RAT-1/RUNTIME_VIEW-1/MRBTS_R-1/EQM_R-1/APEQM_R-1/RMOD_R-2/SFP_R-1",
"configuration": "MRBTS-60001/EQM-1/APEQM-1/RMOD-1/OPT_IF1",
"runtime": "MRBTS-60001/EQM_R-1/APEQM_R-1/RMOD_R-2/SFP_R-1"
},
"sfp": {
"vendor": "WTD",
"vendorPartNumber": "RTXM228-610",
"connectorType": "LC",
"waveLength": "850",
"transmissionMode": "N/A",
"transmissionRate": "6100",
"transmissionDistance": "2.77",
"txPowerHighAlarmThreshold": "-1",
"txPowerLowAlarmThreshold": "-6",
"txPowerHighWarningThreshold": "-2",
"txPowerLowWarningThreshold": "-5",
"rxPowerHighAlarmThreshold": "0",
"rxPowerLowAlarmThreshold": "-20",
"rxPowerHighWarningThreshold": "-1",
"rxPowerLowWarningThreshold": "-18",
"temperatureHighAlarmThreshold": "90",
"temperatureLowAlarmThreshold": "-45",
"temperature": 38,
"voltage": 3319,
"current": 4,
"opticalTxPower": 542.7,
"opticalRxPower": 502.4,
"opticalTxPowerInDbM": -2.654,
"opticalRxPowerInDbM": -2.99,
"BER": 0,
"LCV": "N/A",
"BER_24HR": "N/A",
"bitsReceived": "N/A",
"dateCode": "180302 ",
"diagMonType": "OMA",
"maxTransmissionDistanceList": [
{
"maxLinkLengthType": "Length (SMF,km)",
"sourceMaxLinkLength": {
"maxLinkLength": "N/A",
"maxLinkLengthType": "Length (SMF,km)"
},
"destinationMaxLinkLength": {
"maxLinkLength": "N/A",
"maxLinkLengthType": "Length (SMF,km)"
}
},
{
"maxLinkLengthType": "Length (SMF)",
"sourceMaxLinkLength": {
"maxLinkLength": "N/A",
"maxLinkLengthType": "Length (SMF)"
},
"destinationMaxLinkLength": {
"maxLinkLength": "N/A",
"maxLinkLengthType": "Length (SMF)"
}
},
{
"maxLinkLengthType": "Length (50um)",
"sourceMaxLinkLength": {
"maxLinkLength": "80 in m units",
"maxLinkLengthType": "Length (50um)"
},
"destinationMaxLinkLength": {
"maxLinkLength": "80 in m units",
"maxLinkLengthType": "Length (50um)"
}
},
{
"maxLinkLengthType": "Length (62.5um)",
"sourceMaxLinkLength": {
"maxLinkLength": "30 in m units",
"maxLinkLengthType": "Length (62.5um)"
},
"destinationMaxLinkLength": {
"maxLinkLength": "30 in m units",
"maxLinkLengthType": "Length (62.5um)"
}
},
{
"maxLinkLengthType": "Length (OM4 or copper cable)",
"sourceMaxLinkLength": {
"maxLinkLength": "N/A",
"maxLinkLengthType": "Length (OM4 or copper cable)"
},
"destinationMaxLinkLength": {
"maxLinkLength": "N/A",
"maxLinkLengthType": "Length (OM4 or copper cable)"
}
},
{
"maxLinkLengthType": "Length (OM3)",
"sourceMaxLinkLength": {
"maxLinkLength": "300 in m units",
"maxLinkLengthType": "Length (OM3)"
},
"destinationMaxLinkLength": {
"maxLinkLength": "300 in m units",
"maxLinkLengthType": "Length (OM3)"
}
}
],
"manufactureDate": "180302 ",
"complianceCode": "3",
"vendorRevision": "1.0",
"cableLength": "2.77",
"transceiverTxBiasCurrent": 4,
"serialNumber": "FR180812457",
"maxTransmissionRate": "",
"nokiaPartNumber": ""
},
"linkData": {
"type": "RP3_01Link",
"linkSpeed": "6144.0",
"endPointId": "/MRBTS-1/RAT-1/BTS_L-1/EQM_L-1/CABINET_L-1/BBMOD_L-1/CONNECTOR_L-4",
"extendedId": {
"internal": "/MRBTS-1/RAT-1/RUNTIME_VIEW-1/MRBTS_R-1/EQM_R-1/APEQM_R-1/CABINET_R-1/BBMOD_R-1/SFP_R-1",
"configuration": "MRBTS-60001/EQM-1/APEQM-1/CABINET-1/BBMOD-1/RF3",
"runtime": "MRBTS-60001/EQM_R-1/APEQM_R-1/CABINET_R-1/BBMOD_R-1/SFP_R-1"
},
"firstEndpointCpriState": "A_Disabled",
"secondEndpointCpriState": null,
"firstEndpointCpriSupportedLinkRates": null,
"secondEndpointCpriSupportedLinkRates": null,
"secondEndpointPortId": 1
}
},
"type": "RMOD-1(FRGU)/OPT_IF1"
},
"destination": {
"id": "/MRBTS-1/RAT-1/RUNTIME_VIEW-1/MRBTS_R-1/EQM_R-1/APEQM_R-1/CABINET_R-1/BBMOD_R-1",
"extendedId": {
"internal": "/MRBTS-1/RAT-1/RUNTIME_VIEW-1/MRBTS_R-1/EQM_R-1/APEQM_R-1/CABINET_R-1/BBMOD_R-1",
"configuration": "MRBTS-60001/EQM-1/APEQM-1/CABINET-1/BBMOD-1",
"runtime": "MRBTS-60001/EQM_R-1/APEQM_R-1/CABINET_R-1/BBMOD_R-1"
},
"productName": "Flexi Baseband Sub-Module FBBC",
"serialNumber": "AS180522093",
"productCode": "472797A.101",
"connector": {
"id": "/MRBTS-1/RAT-1/BTS_L-1/EQM_L-1/RMOD_L-2/CONNECTOR_L-1",
"extendedId": {
"internal": "/MRBTS-1/RAT-1/RUNTIME_VIEW-1/MRBTS_R-1/EQM_R-1/APEQM_R-1/CABINET_R-1/BBMOD_R-1/SFP_R-1",
"configuration": "MRBTS-60001/EQM-1/APEQM-1/CABINET-1/BBMOD-1/RF3",
"runtime": "MRBTS-60001/EQM_R-1/APEQM_R-1/CABINET_R-1/BBMOD_R-1/SFP_R-1"
},
"sfp": {
"vendor": "WTD",
"vendorPartNumber": "RTXM228-610",
"connectorType": "LC",
"waveLength": "850",
"transmissionMode": "N/A",
"transmissionRate": "6100",
"transmissionDistance": "2.77",
"txPowerHighAlarmThreshold": "-1",
"txPowerLowAlarmThreshold": "-6",
"txPowerHighWarningThreshold": "-2",
"txPowerLowWarningThreshold": "-5",
"rxPowerHighAlarmThreshold": "0",
"rxPowerLowAlarmThreshold": "-20",
"rxPowerHighWarningThreshold": "-1",
"rxPowerLowWarningThreshold": "-18",
"temperatureHighAlarmThreshold": "90",
"temperatureLowAlarmThreshold": "-45",
"temperature": 59,
"voltage": 3254,
"current": 6,
"opticalTxPower": 542.7,
"opticalRxPower": 502.4,
"opticalTxPowerInDbM": -2.668,
"opticalRxPowerInDbM": -2.741,
"BER": "N/A",
"LCV": 0,
"BER_24HR": "N/A",
"bitsReceived": "N/A",
"dateCode": "170407",
"diagMonType": "OMA",
"maxTransmissionDistanceList": [
{
"maxLinkLengthType": "Length (SMF,km)",
"sourceMaxLinkLength": {
"maxLinkLength": "N/A",
"maxLinkLengthType": "Length (SMF,km)"
},
"destinationMaxLinkLength": {
"maxLinkLength": "N/A",
"maxLinkLengthType": "Length (SMF,km)"
}
},
{
"maxLinkLengthType": "Length (SMF)",
"sourceMaxLinkLength": {
"maxLinkLength": "N/A",
"maxLinkLengthType": "Length (SMF)"
},
"destinationMaxLinkLength": {
"maxLinkLength": "N/A",
"maxLinkLengthType": "Length (SMF)"
}
},
{
"maxLinkLengthType": "Length (50um)",
"sourceMaxLinkLength": {
"maxLinkLength": "80 in m units",
"maxLinkLengthType": "Length (50um)"
},
"destinationMaxLinkLength": {
"maxLinkLength": "80 in m units",
"maxLinkLengthType": "Length (50um)"
}
},
{
"maxLinkLengthType": "Length (62.5um)",
"sourceMaxLinkLength": {
"maxLinkLength": "30 in m units",
"maxLinkLengthType": "Length (62.5um)"
},
"destinationMaxLinkLength": {
"maxLinkLength": "30 in m units",
"maxLinkLengthType": "Length (62.5um)"
}
},
{
"maxLinkLengthType": "Length (OM4 or copper cable)",
"sourceMaxLinkLength": {
"maxLinkLength": "N/A",
"maxLinkLengthType": "Length (OM4 or copper cable)"
},
"destinationMaxLinkLength": {
"maxLinkLength": "N/A",
"maxLinkLengthType": "Length (OM4 or copper cable)"
}
},
{
"maxLinkLengthType": "Length (OM3)",
"sourceMaxLinkLength": {
"maxLinkLength": "300 in m units",
"maxLinkLengthType": "Length (OM3)"
},
"destinationMaxLinkLength": {
"maxLinkLength": "300 in m units",
"maxLinkLengthType": "Length (OM3)"
}
}
],
"manufactureDate": "170407",
"complianceCode": "3",
"vendorRevision": "1.0",
"cableLength": "2.77",
"transceiverTxBiasCurrent": 6,
"serialNumber": "FR171329453",
"maxTransmissionRate": "",
"nokiaPartNumber": ""
},
"linkData": {
"type": "RP3_01Link",
"linkSpeed": "6144.0",
"endPointId": "/MRBTS-1/RAT-1/BTS_L-1/EQM_L-1/CABINET_L-1/BBMOD_L-1/CONNECTOR_L-4",
"extendedId": {
"internal": "/MRBTS-1/RAT-1/RUNTIME_VIEW-1/MRBTS_R-1/EQM_R-1/APEQM_R-1/RMOD_R-2/SFP_R-1",
"configuration": "MRBTS-60001/EQM-1/APEQM-1/RMOD-1/OPT_IF1",
"runtime": "MRBTS-60001/EQM_R-1/APEQM_R-1/RMOD_R-2/SFP_R-1"
},
"firstEndpointCpriState": "A_Disabled",
"secondEndpointCpriState": null,
"firstEndpointCpriSupportedLinkRates": null,
"secondEndpointCpriSupportedLinkRates": null,
"secondEndpointPortId": 1
}
},
"type": "CABINET-1/BBMOD-1(FBBC)/RF3"
}
},
{
"source": {
"id": "/MRBTS-1/RAT-1/RUNTIME_VIEW-1/MRBTS_R-1/EQM_R-1/APEQM_R-1/RMOD_R-1",
"extendedId": {
"internal": "/MRBTS-1/RAT-1/RUNTIME_VIEW-1/MRBTS_R-1/EQM_R-1/APEQM_R-1/RMOD_R-1",
"configuration": "MRBTS-60001/EQM-1/APEQM-1/RMOD-2",
"runtime": "MRBTS-60001/EQM_R-1/APEQM_R-1/RMOD_R-1"
Pour obtenir un fichier final dont les éléments séparés par un point virgule comme le montre ci-dessous
"productName": "FRGU",; "configuration": "MRBTS-60001/EQM-1/APEQM-1/RMOD-1/OPT_IF1",; "opticalTxPowerInDbM": -2.654,; "opticalRxPowerInDbM": -2.99,
"productName": "Flexi Baseband Sub-Module FBBC",; "configuration": "MRBTS-60001/EQM-1/APEQM-1/CABINET-1/BBMOD-1/RF3",; "opticalTxPowerInDbM": -2.668,; "opticalRxPowerInDbM": -2.741,
Merci d'avance
A voir également:
- Rangement des données d'un fichier XML sur la même ligne avec awk
- Comment réduire la taille d'un fichier - Guide
- Fichier bin - Guide
- Comment ouvrir un fichier epub ? - Guide
- Fichier rar - Guide
- Forcer la suppression d'un fichier - Guide
2 réponses
hello
$ awk '{gsub("^ *", "")} /productName/ {printf $0 ";"; n++} /configuration/ && n {printf $0 ";"} /opticalTxPowerInDbM/ && n {printf $0 ";"} /opticalRxPowerInDbM/ {print; n=0}' fichier
"productName": "FRGU",;"configuration": "MRBTS-60001/EQM-1/APEQM-1/RMOD-1/OPT_IF1",;"opticalTxPowerInDbM": -2.654,;"opticalRxPowerInDbM": -2.99,
"productName": "Flexi Baseband Sub-Module FBBC",;"configuration": "MRBTS-60001/EQM-1/APEQM-1/CABINET-1/BBMOD-1/RF3",;"opticalTxPowerInDbM": -2.668,;"opticalRxPowerInDbM": -2.741,