Middlebury

Difference between revisions of "Excel To SQL"

(New page: # Copy from Excel, pasted into text editor # Escape single quotes: Find <code>'</code>, Replace <code>\\'</code>)
 
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
# Copy from Excel, pasted into text editor
 
# Copy from Excel, pasted into text editor
# Escape single quotes: Find <code>'</code>, Replace <code>\\'</code>
+
# Escape single quotes:
 +
#* Find: <code>'</code>
 +
#* Replace: <code>\\'</code>
 +
# Replace tab-delimited with SQL VALUES formatted lines:
 +
#* Find: <code>([^\t\r]*)\t([^\t\r]*)\t([^\t\r]*)\t([^\t\r]*)\t?([^\t\r]*)?\t?([^\t\r]*)?\t?([^\t\r]*)?</code>
 +
#* Replace: <code>('masters', '\1', '\2', '\3', '\4', '\5', '\6', '\7'),</code>
 +
# Remove the last comma from the end of the file.
 +
# Add INSERT statement to top of file:
 +
<pre>INSERT INTO theses
 +
( `group` , `department` , `last_name` , `first_name` , `title` , `year` , `notes` , `alternate_formats`)
 +
VALUES</pre>

Latest revision as of 13:16, 5 October 2007

  1. Copy from Excel, pasted into text editor
  2. Escape single quotes:
    • Find: '
    • Replace: \\'
  3. Replace tab-delimited with SQL VALUES formatted lines:
    • Find: ([^\t\r]*)\t([^\t\r]*)\t([^\t\r]*)\t([^\t\r]*)\t?([^\t\r]*)?\t?([^\t\r]*)?\t?([^\t\r]*)?
    • Replace: ('masters', '\1', '\2', '\3', '\4', '\5', '\6', '\7'),
  4. Remove the last comma from the end of the file.
  5. Add INSERT statement to top of file:
INSERT INTO theses
( `group` , `department` , `last_name` , `first_name` , `title` , `year` , `notes` , `alternate_formats`) 
VALUES
Powered by MediaWiki