Now my question is it takes time to load and save strings to files, so I want to bypass saving and loading the file and load the string value into the database's source. Is it possible?
In line 27 the Source is using data loaded from unsorted.csv, but I want to load %Body% from line 20 directly into Source to save a lot of time & unneeded file read/writing.
Code: Select all
Let>n1=n1+1
DeleteFile>C:\FTP\Zero Hour Calls\Unsorted.csv
CSVFileToArray>Files_%n1%,arrCSV
Let>Comma=,
Let>Body=
Let>x=7
Let>Count=ARRCSV_COUNT-1
WriteLn>C:\FTP\Zero Hour Calls\Unsorted.csv,nWLNRes,Name%Comma%ID%Comma%Time%CRLF%
Let>y=Count-3
While>x<Count
Let>x=x+1
Let>Time=ARRCSV_%x%_0
Let>ID=ARRCSV_%x%_2
//Add>ID,1
Let>Name=ARRCSV_%x%_3
//Let>Line=%Time%%Comma%%ID%%Comma%%Name%%CRLF%
Let>Line=%Name%%Comma%%ID%%Comma%%Time%%CRLF%
Let>Body=%Body%%Line%
EndWhile
WriteLn>C:\FTP\Zero Hour Calls\Unsorted.csv,nWLNRes,%Body%
//new file to write to
Let>new_file=C:\FTP\Zero Hour Calls\Sorted.csv
IfFileExists>new_file
DeleteFile>new_file
Endif
//Connect to OLEDB Database
Let>ConStr=Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\FTP\Zero Hour Calls;Extended Properties='text;HDR=YES;FMT=Delimited'
DBConnect>ConStr,dbH
Let>SQL=select * from unsorted.csv ORDER BY Name,Time
DBQuery>dbH,SQL,fields,num_recs,num_fields
Let>Body=
//If we have records, loop through records and fields, writing out to new file
If>num_recs>0
//first need to copy the header record ...
ReadLn>C:\FTP\Zero Hour Calls\unsorted.csv,1,header_line
WriteLn>new_file,wlnres,%header_line%%CRLF%
Let>rec=0
Repeat>rec
Let>rec=rec+1
Let>field=0
Repeat>field
Let>field=field+1
Let>this_field=fields_%rec%_%field%
//write the field out to the new file
Let>Body=%Body%%this_field%
//add the comma delimiter if needed
If>field<num_fields
Let>Body=%Body%%comma%
Endif
Until>field=num_fields
//add CRLF at end of line
Let>Body=%Body%%CRLF%
Until>rec=num_recs
Endif
DBClose>dbH