Hi,
I have a loop which loops through two arrays two make a header/item file.
for ($x=0; $x -le $header.count-1; $x++)
{
$Headeroutput = @();
$Headeroutput += $header[$x]."Record_Type",$header[$x]."OrderNumber",$header[$x]."OrderDate",$header[$x]."delivery_contact_name",$header[$x]."Company_Name",$header[$x]."delivery_addressline1",$header[$x]."delivery_addressline2",$header[$x]."City",$header[$x]."delivery_post_code",$header[$x]."County",$header[$x]."delivery_country_code",$header[$x]."delivery_contact_number",$header[$x]."email",$header[$x]."Currency_code",$header[$x]."Export_AWB",$header[$x]."Export_Carrier_Name",$header[$x]."Duplicate action",$header[$x]."RMA",$header[$x]."Export_Date",$header[$x]."Free Return",$header[$x]."delivery_addressline3",$header[$x]."Suberb",$header[$x]."Neighborhood",$header[$x]."Custom_field_1",$header[$x]."Custom_field_2",$header[$x]."Custom_field_3",$header[$x]."Custom_field_4",$header[$x]."Custom_field_5"
$Headeroutput -join "," | Out-File $filename -Append -encoding utf8
$iteminfo = @();
$iteminfo = $item | Where-Object {$_."Order_Reference" -eq $header[$x]."OrderNumber" } | Select-Object "Record_Type", "Order_Reference", "SKU_Code", "SKU_Description", "Quantity", "Item_Price", "Unit_Weight", "Weight", "length", "width", "height", "Dimensions_UoM", "HS_Code", "Item_Origin", "ImageURL", "Non_Returnable", "Dangerous_Goods", "Export_Date", "Export_AWB Export_Carrier_Name", "SKU_URL", "Tracking", "Custom_field_1", "Custom_field_2", "Custom_field_3", "Custom_field_4", "Custom_field_5" , "Days for return", "CostPrice"
if($iteminfo.count -eq 1){$test=0}else{$test = $iteminfo.count-1 }
for($y=0; $y -le $test; $y++)
{
$itemoutput = @();
$itemoutput += $iteminfo[$y]."Record_Type", $iteminfo[$y]."SKU_Code", $iteminfo[$y]."SKU_Description", $iteminfo[$y]."Quantity", $iteminfo[$y]."Item_Price", $iteminfo[$y]."Unit_Weight", $iteminfo[$y]."Weight", $iteminfo[$y]."length", $iteminfo[$y]."width", $iteminfo[$y]."height", $iteminfo[$y]."Dimensions_UoM", $iteminfo[$y]."HS_Code", $iteminfo[$y]."Item_Origin", $iteminfo[$y]."ImageURL", $iteminfo[$y]."Non_Returnable", $iteminfo[$y]."Dangerous_Goods", $iteminfo[$y]."Export_Date", $iteminfo[$y]."Export_AWB", $iteminfo[$y]."Export_Carrier_Name", $iteminfo[$y]."SKU_URL", $iteminfo[$y]."Tracking", $iteminfo[$y]."Custom_field_1", $iteminfo[$y]."Custom_field_2", $iteminfo[$y]."Custom_field_3", $iteminfo[$y]."Custom_field_4", $iteminfo[$y]."Custom_field_5", $iteminfo[$y]."Days for return", $iteminfo[$y]."CostPrice"
$itemoutput -join "," | Out-File $filename -Append -encoding utf8
}
}
This is ok for very small files however it dies when the files are 10mb over.. i presume because it having to search through so much information.
Header can be 22551 rows
and the item 111926 rows.
Is there anyway to make it quicker?
Help appreciated.