Created
July 26, 2013 15:30
-
-
Save JamoCA/6089803 to your computer and use it in GitHub Desktop.
AutoHotKey script to convert clipboard columnar data (from Excel or text file) to SQL-compatible comma-delimited list (adds single quotes if data consists of non-numeric values) (Windows+C)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#c:: ;Window+C Convert Columnar Data to SQL-Compatible List | |
StringReplace,clipboard,clipboard,`n,`,,All | |
StringReplace,clipboard,clipboard,`r,,All | |
StringGetPos, pos, clipboard, ID`, ; remove "ID" if first item in the list (Access). | |
if pos = 0 | |
StringRight, clipboard, clipboard, StrLen(clipboard)-3 | |
testString = %clipboard% | |
StringReplace,testString,testString,`,,,All | |
testString := testString * 1 | |
if (testString is integer) { | |
} else { | |
StringReplace,clipboard,clipboard,`,,'`,',All | |
clipboard = '%clipboard%' | |
} | |
Send,^v | |
Return |
Is this what you are looking for?
#c:: ;Window+C Convert columnar data to comma-delimited list within single quotes.
StringReplace,clipboard,clipboard,`n,`,,All
StringReplace,clipboard,clipboard,`r,,All
StringGetPos, pos, clipboard, ID`, ; remove "ID" if it is the first item in the list.
if pos = 0
StringRight, clipboard, clipboard, StrLen(clipboard)-3
clipboard = '%clipboard%'
Send,^v
Return
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey - Thank you so much for this! super helpful!
Quick question - how would it look like if we wanted to paste it all in side a single quote, separated by comma, regardless if that is a string, integer, etc?
Thank you!