TangoWhiskey
Touchdown! Greaser!
Here's a common work problem I run into. Somebody sends me an Excel spreadsheet, one of the columns in it has a list of several server names:
[ROW][CELL]Server1[/CELL][/ROW]
[ROW][CELL]Server2[/CELL][/ROW]
[ROW][CELL]Server3[/CELL][/ROW]
[ROW][CELL]...[/CELL][/ROW]
[ROW][CELL]Server129[/CELL][/ROW]
I copy that list, put it in Word, and use the advanced find-and-replace tools to translate it into a comma separated quoted list like this:
'Server1', 'Server2', 'Server3', '...', 'Server129'
This I then use in a SQL statement to narrow results:
My question is... does anybody have a macro or a utility that will automate the conversion of an Excel copied range of cells into a quoted list of comma-separated values?
I know you Unix gurus will probably tell me how to do this with sed or awk. I do have Cygwin installed, so I can use that option if there's a way to do it with a multi-line list of values.
What I'd REALLY like is a shell shortcut to "Paste as CSV" that I could use with any clipboard text.
P.S.--And again I wonder why the TABLE tag in this forum software inserts so much white space at the top, above the table...
[ROW][CELL]Server1[/CELL][/ROW]
[ROW][CELL]Server2[/CELL][/ROW]
[ROW][CELL]Server3[/CELL][/ROW]
[ROW][CELL]...[/CELL][/ROW]
[ROW][CELL]Server129[/CELL][/ROW]
I copy that list, put it in Word, and use the advanced find-and-replace tools to translate it into a comma separated quoted list like this:
'Server1', 'Server2', 'Server3', '...', 'Server129'
This I then use in a SQL statement to narrow results:
Code:
SELECT STUFF FROM TABLES WHERE SERVERNAME IN ('Server1', 'Server2', 'Server3', '...', 'Server129')
My question is... does anybody have a macro or a utility that will automate the conversion of an Excel copied range of cells into a quoted list of comma-separated values?
I know you Unix gurus will probably tell me how to do this with sed or awk. I do have Cygwin installed, so I can use that option if there's a way to do it with a multi-line list of values.
What I'd REALLY like is a shell shortcut to "Paste as CSV" that I could use with any clipboard text.
P.S.--And again I wonder why the TABLE tag in this forum software inserts so much white space at the top, above the table...