Hi.
I'm not a big fan of
Loop, read, ... or
FileReadLine, ..., when I had to use big files.
I prefer to store the whole content into a variable and then to parse it with
Loop, parse, .....
I even avoid using
FileAppend, ... inside a fast loop or timer.
For this case, I store results into a variable and after closing the loop or timer, I store it on harddisk.
The reason is, that in this way, I had only read and write one times on harddik.
I'm not 250% sure, if
Loop, read, ... accesses the harddisk for every line. For this case, I'm too uneducated.
But
FileAppend, ... accesses the harddisk everytime you use this command.
When your file has, for example, 100.000 lines and you want to report every line with
FileAppend, ..., your harddisk will get accesses 100.000 times.
And if you use
FileAppend, ... inside a fast loop, you should set aside some money to be able to buy a new hard drive, because even SSD-Disk will fail after intensive use of so much accesses in so short time.
So be careful when you use commands, which are accessing the hard drive.
Use RAM for faster results and more gentle behaviour for the harddisk.
Code: Select all
#SingleInstance
;Author Sahil Verma 10/7/2018
SetBatchLines, -1 ; runs the script with maximum speed
x := 1 ; rows of information
y := 1 ; columns of information
z := 0 ; Progress Count
w := 0 ; Temp smoke variable
Array:={} ; saved array information
MotherAge := 30 ; Age of Mother
Previsits := 0 ; Mother Previsits
Weight := 0 ; Birth Weight
Dplural := 1 ; Number of Children
Smoke := "Y" ; N for Not Smoking, Y for Smoking
Filename := "Name of File Goes Here"
; Loop, Read, %Filename%
FileRead, Data, %Filename% ; store content into variable called Data
Loop, parse, Data, `n, `r ; parse Data line for line
{
; total_lines = %A_Index% ; as you do not use total_lines in your disclosed code, you can comment it out.
; FileReadLine, line, %Filename%, %x% ;;Reads Line Fine ; obsolete because you can use A_LoopField
Arr := StrSplit(A_LoopField, ",") ;; Splits Fine, Single Dimension Array @ Arr[1,2,3...,n], TEMP
Loop % Arr.length() - 1 ;; y = 0 at first, x = 1 at first
{
Array[x,y] := Arr[y] ; Perm Array
y += 1
}
w := Array[x,71]
StringReplace, w, w, ",,All"
if(Array[x,10] > MotherAge){ ; Age of mother
if(Array[x,54] > Previsits){ ; Previs
if(Array[x,181] > Weight){ ; dbweight
if(Array[x,165] == Dplural){ ; dplural
if(w = Smoke){
z += 1
NewData .= "`n" . A_LoopField
; FileAppend, %A_LoopField% `n, %MotherAge%-%Previsits%-%Weight%-%Dplural%-%Smoke%-%Filename%
}
}
}
}
}
; ToolTip % "Confirmed: " . z . " | Checked: " . x " | Percentage Retained: " . (z/x)*100 "% ", 1900, 1000
; x += 1
; y := 1
}
FileAppend, % LTrim(NewData, "`n"), %MotherAge%-%Previsits%-%Weight%-%Dplural%-%Smoke%-%Filename%, UTF-8
; FileAppend, LTrim(NewData, "`n"), %MotherAge%-%Previsits%-%Weight%-%Dplural%-%Smoke%-%Filename%, UTF-8 ; if line above not works, try this line ( All untested :)
return
x::ExitApp
Maybe my suggestion combined with code of
just me could boost the whole process.