Automating prep work for SQL in list query of hundreds-thousands of items

 

SQL in List

Often I have a list of hundreds (sometimes thousands) of items that I need to insert into a  query. Unfortunately I can only add 99 items at a time.

This video demonstrates how my script replaces the first 98 line breaks with commas and wrap items already having a comma with special characters to escape them.    This is perfect for my SQL in list query!  What would have taken me several minutes or longer is now done in the blink of an eye  (while also escaping illegal characters).  The below video demonstrates it’s usage and further down the page is the AutoHotkey code that cranks it out!

 

Video demonstrating how the SQL in list works

 

AutoHotkey code:

Windows autocorrect- Use AutoHotKey to replace text in any Windows program

windows autocorrect

Windows autocorrect- Adding HotStrings in AutoHotKey

For about 20 years I loved using autocorrect feature in Word and Excel to help me write commonly used phrases.  Unfortunately, at that time, MS office didn’t sync across programs so I had to maintain my list of corrections in each program.  Worse yet; I also had to repeat it on every computer that I used.

About a decade ago I read an article which mentioned AutoHotKey had built in “Hotstrings” which provided a similar functionality but would work in any windows program.  (AutoHotKey has a ton of other great features but this is the one that has the largest appeal to the most users.)

I think of hotstrings and a windows autocorrect.  Used intelligently you can tell the computer when I type a few letters, replace the abbreviation I just typed with a full sentence, paragraph, etc.  It is fairly easy to add Hotstrings in AutoHotKey however there is a script which speeds-up the process.  The below video walks through the process.

Text file explorer-Determine file headers & delimiters without opening file

Text file explorer

Text File ExplorerText file explorer

I often work with large text files in which the file extension (.txt, .dat, .csv, .tab) doesn’t always indicate what type of delimiter is used in the file.  When the file is small, I’ll typically just “pop” it open in SciTE / Notepad.  Large files (anything over 20 megs) often take a fair amount of time to read and very large files ( a gig or more) will often run into out of memory issues.

On top of wanting to know the delimiter, I also frequently want to know what fields / Headers are in the file.   This normally means I have to open it in a text editor or Excel and review.  I wrote the below Text File Explorer in AutoHotkey script to simplify the above.  I can highlight a file from Windows Explorer and quickly detect the type of delimiter plus display headers if I care to.

Text file explorer AutoHotkey code:


Here’s a video demonstrating the usage of the Text file Explorer