Hi guys,
finaly i got my code working.
it takes the 3 line and last line from a 15 file's in a dir.
the last line is split in two parts, the part after the ; i am interested in.
then i join all the line's to one line in a textfile with a ; as value separation character, after that all , are replaced for a dot.
now i have the file i can use.
this file:
W
-10496
mnuPowerIn
63581203668;210,34
63581203728;203,46
63581203788;204,65
and this file
W
-10496
mnuPower
63581203668;166,81
63581203728;165,45
63581203788;164,64
and more of these files are converted in this:
Inverter #2 - mnuCurrent;0.83;Inverter #2 - mnuTodayEnergy;447.00;mnuPower;164.64;Inverter #2 - mnuPower;153.78;mnuPowerIn;204.65;Inverter #2 - PV1 - mnuCurrent;0.65;Inverter #2 - PV1 - mnuPower;193.28;Inverter #2 - PV1 - mnuVoltage;292.86;Inverter #2 - PV2 - mnuCurrent;1.83;Inverter #2 - PV2 - mnuPower;0.30;Inverter #2 - PV2 - mnuVoltage;0.24;Inverter #2 - lblTempTINT;38.22;mnuTodayEnergy;447.00;Inverter #2 - lblTempTI;41.26;Inverter #2 - mnuVoltage;223.85;Inverter #2 - lblGenFreqT;0.00
do far so good.
The computer who has to run the script is not very fast.
can some one tell me who to make the code less processor time hungry ?
Also i want to get rid of the extra outputfiles.
is there a way to do all of this and have only one output file ?
this is the code:
$input_path = ‘e:\a\*.tmp’
$fileDirectory = ‘e:\a’
$output_file = ‘e:\b\output.txt’
Clear-Content $output_file
Clear-Content e:\b\output1.txt
Clear-Content e:\b\output2.txt
foreach($file in Get-ChildItem $fileDirectory )
{
$filePath = $fileDirectory + "\" + $file;
$A=(get-content $filePath -totalcount 3)[-1]
$B=get-content $filePath -tail 1
Add-Content $output_file $A
$parts = $B.split(";")
Add-Content $output_file $parts[1]
}
$c=(Get-Content $output_file) -Join ";"
Add-Content e:\b\output1.txt $c
(get-content e:\b\output1.txt) -replace ',',"." | Add-content e:\b\output2.txt
thanks in advanced