My Infil looks like: (17 fields and about 30000 rows)
"aaaaa";"abcdes";"asdfghjkl";"asdfdsa";"";"";"32323";....;"234323"
"bbb";"abcde123";"";"";"sdfsa";.......;""
And so on
Why does it take about 90sek on my Thinkpad to run
I think it's about 5500 rows I clean with this function.
After all I wrote a logfile with information / statistic
about the cleaning
Now I have this 8 rules to clean,
maybe It can be more or less
Code:
SetBatchLines, -1
Process, Priority,, High
Fields = 17
AllRows := Clean(Infil_Out, Fields)
ExitApp
; - - - - - - - - - - - - - - - - - - - -
; - - - - - Function Clean - - - - - - - - - - - - - -
; - - - - - - - - - - - - - - - - - - - -
Clean(Fil_In, FieldNo)
{
Global
Loop parse, Fil_In, `n, `r
{
RowOut_%A_Index% := A_LoopField
ArtRow := RowOut_%A_Index% ; More easy to use
StringLen RowLength, ArtRow
StringSplit Field_, ArtRow, `;, %A_Space%%A_TAB%`"
; ----------------------------------------------------------
; 1. Clean empty rows -(maybe i don't need this control)
; - - - - - - - - - - - - - - - - - - - -
If RowLength = 0 {
Log_1 := Log_1 "Some log 1 info"
Count_1 ++
Continue ; Jump to Next Row
}
; ----------------------------------------------------------
; ----------------------------------------------------------
; 2. Clean Rows more then 423 char
; - - - - - - - - - - - - - - - - - - - -
If RowLength > 423 {
Log_2 := Log_2 "Some log 2 info"
Count_2 ++
Continue ; Jump to Next Row
}
; ----------------------------------------------------------
; ----------------------------------------------------------
; 3. Clean Rows with not 17 fields
; - - - - - - - - - - - - - - - - - - - -
IfNotEqual Field_0, %FieldNo% {
Log_3 := Log_3 "Some log 3 info"
Count_3 ++
Continue ; Jump to Next Row
}
; ----------------------------------------------------------
; ----------------------------------------------------------
; 4. If Field_8 = Empty - Clean
; - - - - - - - - - - - - - - - - - - - -
If StrLen(Field_8) = 0 {
Log_4 := Log_4 "Some log 4 info"
Count_4 ++
Continue ; Jump to Next Row
}
; ----------------------------------------------------------
; ----------------------------------------------------------
; 5. If Field_8 => more than nine chars - Clean
; - - - - - - - - - - - - - - - - - - - -
If StrLen(Field_8) > 9 {
Log_5 := Log_5 "Some log 5 info"
Count_5 ++
Continue ; Jump to Next Row
}
; ----------------------------------------------------------
; ----------------------------------------------------------
; 6. If Field_2 empty - Clean
; - - - - - - - - - - - - - - - - - - - -
If StrLen(Field_2) = 0 {
Log_6 := Log_6 "Some log 6 info"
Count_6 ++
Continue ; Jump to Next Row
}
; ----------------------------------------------------------
; ----------------------------------------------------------
; 7. If Field_1 empty and Field_3 not empty - copy 3 to 1
; - - - - - - - - - - - - - - - - - - - -
If (StrLen(Field_1)=0) and (StrLen(Field_3)=0) {
Log_7 := Log_7 "Some log 7 info"
Count_7 ++
Continue ; Jump to Next Row
}
; ----------------------------------------------------------
; ----------------------------------------------------------
; 8. If Field_1 more then 13 char - clean
; - - - - - - - - - - - - - - - - - - - -
StringLen, RowTemp, Field_1
If RowTemp > 13 {
Log_8 := Log_8 "Some log 8 info"
Count_8 ++
Continue ; Jump to Next Row
}
; ----------------------------------------------------------
ArtNr ++
NewRow_%ArtNr% = %ArtRow%
}
Loop %ArtNr%
AllRows .= NewRow_%A_Index% . ( A_Index < ArtNr ? "`n" : "" )
Return AllRows
}
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -