Scripting Blog [archived]

Formerly known as the "Hey, Scripting Guy!" blog

Hey, Scripting Guy! How Can I Replace a Series of Variables Found in a Text File with Values Taken From That File?

(image) Hey, Scripting Guy! I have a text file containing TSQL syntax. In this file are a number of variables: @P1, @P2, @p3, and so on, up through @P58. The bottom line of the text file contains replacement values for these variables; for example, I need to take the variable @P1 and replace it with the first value in the last line; I need ...

Hey, Scripting Guy! How Can I Prevent Office Excel From Turning My Imported Numbers Into Dates?

(image) Hey, Scripting Guy! I have a CSV file, and every time I open that file in Office Excel my numbers get converted to dates. How can I import numbers as numbers?-- JR (image) (image) (image) Hey, JR. You know, just yesterday the Scripting Guy who writes this column learned about Yelo, an interesting little company based in New York City...

Hey, Scripting Guy! How Can I Remove Specified Commas from a Comma-Separated Values File?

(image) Hey, Scripting Guy! I have a comma-separated values file in which several fields have a comma embedded in the field value; that’s causing problems when I try and import the information into another application. I was wondering if there is a way to remove all the commas that are enclosed inside double quote marks, leaving all the ...

Hey, Scripting Guy! How Can I Remove Delimiters, and Fix Apostrophes, in a CSV File?

(image) Hey, Scripting Guy! I have a comma-separated values file (CSV) that uses double quote marks as the field delimiter; unfortunately, this file also uses a double quote mark any time it should use an apostrophe (like in the name O’Malleys). Somehow I need to remove all the delimiters and convert the appropriate double quote marks to ...

Hey, Scripting Guy! How Can I Modify a .CSV File and Then Import That File into Microsoft Excel?

(image) Hey, Scripting Guy! I have a comma-separated values file that I need to import into Excel. However, before I do that I need to do some arithmetic and then add an additional field to the CSV file. On top of that, when I import this file I need to format this new field as a date-time value. How can I do that?-- R(image) (image) (image...