New Commands: ArrayToCSVFile and DBQueryToCSV

Ideas for new features & functions

Moderators: Dorian (MJT support), JRL

Post Reply
mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

New Commands: ArrayToCSVFile and DBQueryToCSV

Post by mightycpa » Thu Mar 05, 2015 8:25 pm

I find that the existing function CSVFileToArray can be incredibly fast and useful for loading structured data. The inverse function would be an excellent addition to the toolbox.

In my case, for this:

Code: Select all

...
ReadFile>E:\macroscheduler\iw_apply_glossary_3.sql,v_sql_3
DBConnect>Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=True;Initial Catalog=MyDB;Data Source=server;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=mpc;Use Encryption for Data=False;Tag with column collation when possible=False,DEV_CPA7
DBQuery>DEV_CPA7,%v_sql_3%,REC_FOUND,NumRecs,NumFields,0
DBClose>DEV_CPA7
//Reads in about 700 records

//write contents to CSV for storage purposes
ArrayToCSVFile>REC_FOUND,E:\macroscheduler\dialog_loader.csv

//load CSV to dialog
ReadFile>E:\macroscheduler\dialog_loader.csv,CSVFileData
SetDialogProperty>Dialog1,MSStringGrid1,LoadFromCSV,CSVFileData
...
The command DBQueryToCSV would format the query results in a CSV format, for direct loading to a dialog, like so:

Code: Select all

...
ReadFile>E:\macroscheduler\iw_apply_glossary_3.sql,v_sql_3
DBConnect>Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=True;Initial Catalog=MyDB;Data Source=server;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=mpc;Use Encryption for Data=False;Tag with column collation when possible=False,DEV_CPA7
DBQueryToCSV>DEV_CPA7,%v_sql_3%,REC_FOUND,NumRecs,NumFields,0
DBClose>DEV_CPA7
//Reads in about 700 records
SetDialogProperty>Dialog1,MSStringGrid1,LoadFromCSV,REC_FOUND
...
How cool would that be?
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: New Commands: ArrayToCSVFile and DBQueryToCSV

Post by Marcus Tettmar » Mon Mar 09, 2015 9:56 am

Thanks for the suggestions. I've added them to the wish list.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts