2007/10/11

U.S. States CSV / SQL

I needed a mySQL table containing the common names of the U.S. States and their two letter abbreviations. I quickly Googled and couldn't find anything. Maybe I didn't search long enough. All I found was a Wikipedia article that listed them.

I grabbed the contents, formatted them with BBEdit to a CSV and imported them into mySQL. Just so no one else has to do that, here you go: state.csv, state.sql

Hope this helps someone.

Labels: , ,

26 Comments:

Anonymous Anonymous said...

Thanks. I needed this quickly and got it off your site. It did come in handy.

12/04/2007 3:43 PM  
Blogger Scott said...

If anyone who comes across this finds any variant of the information useful, such as a Tab file, let me know and I can add it. Also if anyone has any similar types of info, like Canadian Territories, I'd happily post that as well.

12/04/2007 5:40 PM  
Anonymous Anonymous said...

thanks a lot saved me some time.

3/19/2008 5:42 PM  
Anonymous Anonymous said...

rock on. thanks. helped a bunch.

4/08/2008 12:33 AM  
Anonymous Stephen said...

Nice one, thanks for making this available.

Cheers,
Stephen

4/11/2008 3:38 AM  
Anonymous Anonymous said...

thanks!

4/12/2008 6:00 AM  
Blogger Myles Bostwick said...

Your generosity is greatly appreciated! Thanks for thinking of others!

4/21/2008 4:06 PM  
Blogger Mark D. said...

thanks for the sql script!

5/10/2008 10:06 PM  
Blogger Matthew R Hall said...

Thanks, saved me some time. Good karma heading your way!

5/30/2008 11:24 AM  
Anonymous Harmony said...

Thanks, Scott! You helped me out as well!

Cheers!

6/17/2008 8:32 AM  
Anonymous Jerimiah Brown said...

Thanks a bunch. Your list has saved me time on more than one occasion.

6/23/2008 9:43 PM  
Blogger Xander said...

Thank you, was going to grab off Wikipedia :D

7/05/2008 8:49 PM  
Anonymous Anthony said...

Thank You SOOOOO MUCH!

7/21/2008 6:34 PM  
Blogger Alexis said...

awesome, thanks, couldn't believe i couldn't find it anywhere else.

7/23/2008 11:48 AM  
Anonymous Renegade said...

Thanks a ton.
Just what I was looking for!

7/31/2008 6:02 AM  
Anonymous Randall said...

Thanks for the files.

This file is from phpMyAdmin like yours. However it was not outputted but copied and pasted which is easier to read and edit.

I added some codes for USA non states (e.g. Virgin Islands). Created better names. If you replace RegionsT with a table name you like (e.g. StatesT) before you import, your work is finished.

I am also looking for Country codes, Postal codes, etc.

I am trying to maintain a global sense - hince RegionsT rather than StatesT.

-- phpMyAdmin SQL Dump
-- version 2.11.8.1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Aug 12, 2008 at 05:05 PM
-- Server version: 5.0.51
-- PHP Version: 5.2.6

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";

--
-- Database: `template`
--

-- --------------------------------------------------------

--
-- Table structure for table `RegionsT`
--

DROP TABLE IF EXISTS `RegionsT`;
CREATE TABLE IF NOT EXISTS `RegionsT` (
`Name` varchar(50) NOT NULL,
`Abbr` char(2) NOT NULL,
PRIMARY KEY (`Abbr`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

--
-- Dumping data for table `RegionsT`
--

INSERT INTO `RegionsT` (`Name`, `Abbr`) VALUES
('Armed Forces - Americas', 'AA'),
('Armed Forces - Europe', 'AE'),
('Armed Forces - Africa', 'AF'),
('Alaska', 'AK'),
('Alabama', 'AL'),
('Armed Forces - Pacific', 'AP'),
('Arkansas', 'AR'),
('American Samoa', 'AS'),
('Arizona', 'AZ'),
('California', 'CA'),
('Colorado', 'CO'),
('Connecticut', 'CT'),
('District of Columbia', 'DC'),
('Delaware', 'DE'),
('Florida', 'FL'),
('Federated States of Micronesia', 'FM'),
('Georgia', 'GA'),
('Hawaii', 'HI'),
('Iowa', 'IA'),
('Idaho', 'ID'),
('Illinois', 'IL'),
('Indiana', 'IN'),
('Kansas', 'KS'),
('Kentucky', 'KY'),
('Louisiana', 'LA'),
('Massachusetts', 'MA'),
('Maryland', 'MD'),
('Maine', 'ME'),
('Marshall Islands', 'MH'),
('Michigan', 'MI'),
('Minnesota', 'MN'),
('Missouri', 'MO'),
('Northern Mariana Islands', 'MP'),
('Mississippi', 'MS'),
('Montana', 'MT'),
('North Carolina', 'NC'),
('North Dakota', 'ND'),
('Nebraska', 'NE'),
('New Hampshire', 'NH'),
('New Jersey', 'NJ'),
('New Mexico', 'NM'),
('Nevada', 'NV'),
('New York', 'NY'),
('Ohio', 'OH'),
('Oklahoma', 'OK'),
('Oregon', 'OR'),
('Pennsylvania', 'PA'),
('Puerto Rico', 'PR'),
('Palau', 'PW'),
('Rhode Island', 'RI'),
('South Carolina', 'SC'),
('South Dakota', 'SD'),
('Tennessee', 'TN'),
('Texas', 'TX'),
('Utah', 'UT'),
('Virginia', 'VA'),
('Virgin Islands', 'VI'),
('Vermont', 'VT'),
('Washington', 'WA'),
('Wisconsin', 'WI'),
('West Virginia', 'WV'),
('Wyoming', 'WY');

8/12/2008 10:18 PM  
Anonymous Anonymous said...

I used this today. Thanks.

9/03/2008 2:13 AM  
Anonymous Ali said...

thanks so much baby

9/11/2008 11:11 AM  
Anonymous Chadwick Meyer said...

Thanks, that was helpful. Those looking for a postal code list with lat/long will find this helpful as well:
http://www.aggdata.com/free/zip-code

9/22/2008 7:05 PM  
Anonymous Anonymous said...

Very handy, thanks!

10/07/2008 5:41 PM  
Anonymous Anonymous said...

Thank you so much.

10/25/2008 11:35 AM  
Anonymous Sam said...

Much appreciated. Thank you!

10/28/2008 6:15 PM  
Anonymous John said...

thanks!!! This really helped me and saved a lot of time!!!

10/29/2008 2:45 PM  
Blogger Spoom said...

Hi Scott,

Found your list quite useful. I added Canadian provinces for a site I'm working on so I figured I would post it here.

"Alberta","AB"
"British Columbia ","BC"
"Manitoba","MB"
"New Brunswick","NB"
"New Foundland","NL"
"Northwest Territories","NT"
"Nova Scotia","NS"
"Nunavut","NU"
"Ontario","ON"
"Prince Edward Island","PE"
"Quebec","QC"
"Saskatchewan","SK"
"Yukon Territory","YT"
"Alabama","AL"
"Alaska","AK"
"Arizona","AZ"
"Arkansas","AR"
"California","CA"
"Colorado","CO"
"Connecticut","CT"
"Delaware","DE"
"Florida","FL"
"Georgia","GA"
"Hawaii","HI"
"Idaho","ID"
"Illinois","IL"
"Indiana","IN"
"Iowa","IA"
"Kansas","KS"
"Kentucky","KY"
"Louisiana","LA"
"Maine","ME"
"Maryland","MD"
"Massachusetts","MA"
"Michigan","MI"
"Minnesota","MN"
"Mississippi","MS"
"Missouri","MO"
"Montana","MT"
"Nebraska","NE"
"Nevada","NV"
"New Hampshire","NH"
"New Jersey","NJ"
"New Mexico","NM"
"New York","NY"
"North Carolina","NC"
"North Dakota","ND"
"Ohio","OH"
"Oklahoma","OK"
"Oregon","OR"
"Pennsylvania","PA"
"Rhode Island","RI"
"South Carolina","SC"
"South Dakota","SD"
"Tennessee","TN"
"Texas","TX"
"Utah","UT"
"Vermont","VT"
"Virginia","VA"
"Washington","WA"
"West Virginia","WV"
"Wisconsin","WI"
"Wyoming","WY"

11/13/2008 8:35 AM  
Blogger Nikolai Rasputin said...

Thank you oh so very much.

12/05/2008 7:23 AM  
Anonymous Anonymous said...

Thanks!

Dan Moore

12/05/2008 7:14 PM  

Post a Comment

Links to this post:

Create a Link

<< Home