Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

read a large line? how can faster finish and split

$
0
0

gc $Tp2Composite_path="tp.txt"

$tp2composite_content= gc $Tp2Composite_path | where-object{$_ -ne ''}
$tag_content = gc $tag_report_path
$composite_ID_split=@{}
$TPIDobject_array=@()
$tp_ID=@{}
$tp_idid=@()
$TPIDobject=@{}
for($index_compositeID=2;$index_compositeID -lt$tp2composite_content.length;$index_compositeID++)
{
    $tpID_line=$tp2composite_content[$index_compositeID]-split ";"
    $tpID=$tpID_line[1]-split "\."
    $tp_ID[$index_compositeID-2]=$tpID_line[0]
    $tp_idid=$tp_idid +$tp_ID[$index_compositeID-2]
    $TPIDobject[$index_compositeID-2]=new-object System.object
    $TPIDobject[$index_compositeID-2] | Add-Member -type NoteProperty -name ID_SU -value $tpID[0]
    $TPIDobject[$index_compositeID-2] | Add-Member -type NoteProperty -name ID_DEP -value $tpID[1]
    $TPIDobject[$index_compositeID-2] | Add-Member -type NoteProperty -name ID_DEV -value $tpID[2]
    $TPIDobject[$index_compositeID-2] | Add-Member -type NoteProperty -name ID_PO -value  $tpID[3]
    $TPIDobject[$index_compositeID-2] | Add-Member -type NoteProperty -name DEV_NA -value  $tpID_line[6]
    $TPIDobject_array +=$TPIDobject[$index_compositeID-2]
}

 

the tp.txt file have 99587 line.

use for loop split and add new-object System.object,and then run the program, use 25mins finish the program.

any suggest can faster finish read 99587 line and split and add new-object System.object?


Viewing all articles
Browse latest Browse all 6937

Trending Articles