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

poweshell write a large data to text file very slower?

$
0
0

first the program read the about 80000 line data,spilt the line,and then write the split object,finish the write text file about 1 hours,very slower,how can i do? 

$m_point = Select-String -pattern  ",T," c:\temp\test\mt_point.txt
For ($x=0; $x -le $m_point.length; $x++)
#For ($x=0; $x -le 2; $x++)

{
    $s_point = $m_point[$x] -split ","
   $s_point = $s_point -replace ''''
  # echo $s_point[10]
   $point_ID=$s_point[2]+"."+$s_point[3]+"."+$s_point[4]+"."+$s_point[5]
   # echo $point_ID
        $Sel = Select-String  -pattern $point_ID -path $Location
        $tp_point_stirng= $Sel-split ";"
      # echo $tp_point_stirng[6]
       # echo $tp_point_stirng[7]
        $tp_point_no=$tp_point_stirng[0]-split ":"
        $tp_point=$tp_point_no[3]-split ","
        #echo $tp_point[1]
   if($point_ID  -eq $tp_point_stirng[1])
   {
    if($s_point[6]-eq "T")
    {
        $Nis_point="!1!"+$tp_point[1]+"!"+$s_point[2]+ "!"+$tp_point_stirng[7]+"!0!SI!!"+$s_point[7]+"!!!!"+ $s_point[8]+"!"
        $Nis_point | out-file -filepath $fname_tag -Append
       
    }
     if($s_point[9]-eq "T")
    {
        $Nis_point="!1!"+$tp_point[1]+"!"+$s_point[2]+ "!"+$tp_point_stirng[7]+"!2!AI!!"+$s_point[10]+"!!!!"+ $s_point[11]+"!"
        $Nis_point | out-file -filepath $fname_tag -Append
    }
    if($s_point[12] -eq "T" -or $s_point[13] -eq "T")
    {
        if($s_point[14] -eq "F" -or $s_point[15] -eq "F")
        {
           $SDID_XDIS= "1"+","+$tp_point[1]+",0"
           $SDID_XDIS | out-file -filepath $fname_mu -Append
        }
        if($s_point[14] -eq "T" -or $s_point[15] -eq "F")
        {
           $SDID_XDIS="1"+","+$tp_point[1]+",1"
           $SDID_XDIS | out-file -filepath $fname_mu -Append
        }
        if($s_point[14] -eq "F" -or $s_point[15] -eq "F")
        {
           $SDID_XDIS= "1"+","+$tp_point[1]+",2"
           $SDID_XDIS | out-file -filepath $fname_mu -Append
        }
        if($s_point[14] -eq "T" -or $s_point[15] -eq "T")
        {
           $SDID_XDIS= "1"+","+$tp_point[1]+",3"
           $SDID_XDIS | out-file -filepath $fname_mu -Append
        }
    }
    }
}


Viewing all articles
Browse latest Browse all 6937

Trending Articles