the Text stays as : ,,,,
file2 is bigger than file1 in number of lines.
What i am trying to do is matching Ticker field in 2 csv files. when match is found lines are merged. If no match found then the minimum info is retained by adding empty commas.
but after 4 empty commas the minimum info (line2) is not getting added.
Code: Select all
Text =
Line1 =
Line2 =
Line3 =
Text2 =
FileRead,File1,Y:\Data\Ordermodify.txt
FileRead,File2,Y:\Data\Portfolio.txt
Loop,Parse,File2, `n
{
Line1 := A_LoopField
linearray1 := StrSplit(Line1, ",")
Ticker1 := linearray1.3
Qty := linearray1.4
nowPrice := linearray1.5
EntryPrice := linearray1.7
Loop,Parse,File1, `n
{
Line2 := A_LoopField
linearray2 := StrSplit(Line2, ",")
Ticker2 := linearray2.27
Qty2 := linearray2.30
if ( (ticker1 = ticker2) )
{
Text := Text . ticker2 . "," . Qty2 . "," . Entryprice . "," . nowprice . "," . Line2 . "`n"
Break
}
}
if ( (ticker1 != ticker2) )
{
Text := Text . "," . "," . "," . "," . Line3 . "`n"
;Break
}
}
filedelete,Y:\data\matched_OM_PF.txt
fileappend,%Text%,Y:\data\matched_OM_PF.txt
Return