There might be a way to set up a schema.ini file to deal with your semicolon delimited file structure via SQL. There is also probably a regex solution out there somewhere. However, my skills are limited so here is a simple parsing routine. It works with the sample text you provided. Assuming the sample accurately represents the file structure possibilities it should give you accurate results. Speed might become an issue on large files.
Be sure to change the first line to reflect your file name and location.
Hope this is helpful,
Dick
Code: Select all
Let>vFileName=Path and name of your file
ReadFile>vFileName,var
Separate>var,crlf,vLine
Let>comma=,
Let>Col7Sum=0
Let>kk=0
Repeat>kk
Add>kk,1
Let>Value=vLine_%kk%
Separate>Value,;,vItem
//The following attempts to parse within the conditions you have specified for your file structure
Let>kkk=0
Let>kkkk=0
Repeat>kkk
add>kkk,1
add>kkkk,1
Let>Valuee=vItem_%kkk%
Length>Valuee,Len
MidStr>Valuee,len,1,testChar
If>TestChar<>"
Midstr>Valuee,1,1,testchar
If>testchar="
Add>kkk,1
Let>Valueee=vItem_%kkk%
Midstr>Valueee,1,1,testchar
If>testchar<>"
Length>Valueee,Len
MidStr>Valueee,len,1,testChar
If>testchar="
Let>valuee=%valuee%;%valueee%
Else
sub>kkk,1
EndIf
EndIf
EndIF
EndIf
////////////////////////////////////// End of parsing /////////////////////////////////////////
//kkkk value is the column to sum
If>kkkk=7
StringReplace>valuee,",,valuee
StringReplace>valuee,comma,.,valuee
Add>Col7Sum,valuee
EndIf
Until>kkk=vItem_Count
Until>kk=vLine_count
Timer>stop
StringReplace>Col7Sum,.,comma,Col7Sum
MDL>Col7Sum