Before attempting to convert any spreadsheet, it is best to review the data for consistency. For example, make sure that every row has the same number of columns and check that all dates are formatted in the same way. This may save major headaches by helping to spot errors early.
How you convert a spreadsheet to a text file may depend upon the
OS you are using. If you are working under Windows with an Excel
spreadsheet, open the spreadsheet in Excel and choose the
Save As menu option under the
File menu. From the Save as
type list box choose the Text(Tab
delimited) option.
Under Unix, Windows, or Mac you can use OpenOffice Calc to open a
variety of spreadsheet formats, including an Excel spreadsheet.
Export the spreadsheet from the Calc application by choosing the
File and Save as menu
options. Next choose Text CSV from the
Filter list box. This opens a dialog box for
further refining your choice. Choose the character set
Unicode or a platform-specific format, if
appropriate. As a field delimiter choose the
{Tab} option and no text delimiter at all. The
drop-down list box only offers single or double quotation marks as
alternatives; to choose no delimiter simply delete the quotation
mark.
If you are using an application that won't let you save the spreadsheet in tab-separated format, a Google spreadsheet for example, then simply save the file as a CSV file. Tab-separated text files are the easiest to import into MySQL but importing a CSV file is almost as simple. Before saving the file, review the contents first and ensure that no commas appear anywhere in the data. A stray comma can cause data corruption or complete failure when importing data in CSV format.
Save the file as data.tsv (or as
data.csv if the format is comma-separated),
have a look at the exported data in a text editor. Each record
should appear on a separate line. Don't be concerned if each line
is not a uniform length. Many programs will export the column
headings as the first row of the text file. Delete this row and
resave the file, making sure that you save it as a text file and
don't introduce any formatting.
