301
Post New Requests Here / Re: NetTraffic xml export to Excel
« on: February 13, 2019, 03:17 PM »
Well, I mocked up a batchfile, using xmlstarlet to be downloaded here, that converts all "NetTraffic <date-time>.xml" files of current directory into a single NetTrafficAll.csv file.
(Used the PowerShell highlighter as Batch isn't supported by the board)
You'll need to adjust the path to the xml.exe file, and check the other settings as 'documented'
NOTE: No data-conversions done here, Excel can do that better and easier
NOTE2: The csv file will be fully replaced each run of the script!
(Used the PowerShell highlighter as Batch isn't supported by the board)
You'll need to adjust the path to the xml.exe file, and check the other settings as 'documented'
NOTE: No data-conversions done here, Excel can do that better and easier
Code: PowerShell [Select]
- @echo off
- :: Set the relative path to your xmlstarlet install:
- set XML=..\Downloads\XML\xmlstarlet-1.6.1\xml.exe
- :: Change filemask if desired
- set "FILEMASK=NetTraffic 2*.xml"
- :: Change result outputfile as desired, keep the .csv extension, when adding spaces, surround with quotes like FILEMASK
- set OUTFILE=NetTrafficAll.csv
- :: Add StatHour to this list if desired
- set "ELEMENTS=StatYear StatMonth StatDay"
- :: Choose csv separator, either , (comma) or ; (semicolon)
- set CSVSEP=;
- set XMLARG1=sel -T -t -m NetTraffic/
- set XMLARG2=/key -v "concat('
- set XMLARG3=%CSVSEP%',@ts,'%CSVSEP%',@tm,'%CSVSEP%',@dl,'%CSVSEP%',@ul,'%CSVSEP%',@dx,'%CSVSEP%',@dy)" -n
- :: Write header
- echo Period%CSVSEP%ts%CSVSEP%tm%CSVSEP%dl%CSVSEP%du%CSVSEP%dx%CSVSEP%dy>"%OUTFILE%"
- :: Loop all files from FILEMASK
- for %%F in ("%FILEMASK%") do (
- echo File: %%F
- :: Fetch all configured elements
- for %%G in (%ELEMENTS%) do (
- %XML% %XMLARG1%%%G%XMLARG2%%%G%XMLARG3% "%%F" >>"%OUTFILE%"
- )
- )
NOTE2: The csv file will be fully replaced each run of the script!