Wednesday, June 25, 2008

Opening CSV or Text Files as Calc Spreadsheets--and Vice Versa

(link to original post)
When I worked at Sun, there were a few things people always asked, that were hard to figure out.

- How do you print the same rows or columns on every page of a spreadsheet? (See this post. )

- How do you print handouts for a presentation? (See this post.)

- How do you get a blank paragraph line above a table that's at the top of a document? (You now simply have to press Return in the upper left cell of the table.)

Another very common question was:

How in the world do you open a perfectly good .txt or .csv file (comma-separated values) in a spreadsheet? Basically, you've got data in rows and columns, but separated by tabs or commas rather than columns in a spreadsheet, and you want it in a spreadsheet. Comma-delimted files are a common way to get data out of a spreadsheet or database and into another.

The trouble is, in OpenOffice.org, if you just choose File > Open, the .txt or .csv file opens in Writer. Not what you want.

Csv1_1

Here's how to open it in a Calc spreadsheet.

Opening a .txt or .csv File in a Calc Spreadsheet

1. Start OpenOffice.org. You can be in Writer, Draw, Calc—it doesn't matter.

2. Choose File > Open. (Click the picture to see a larger version of it, if you want.)

Csv0_1

3. In the File Type list, select Text CSV. It's about a third of the way down the list of types, or you can click in the file type list and press T four times.

List_2

4. The window should now look like this, so just click Open.

Csv2

5. You'll get a window where you specify how the file was created: what separates the data into columns, etc. (Click the picture to see a larger version, if you want.)

Csv3

6. Also in the same window, if you have date-format data or other formats you want to specify, you can do that column by column.

Csv4

7. When you're done, just click OK. You'll see the data in a spreadsheet.

Csv5

8. You'll want to save it as a spreadsheet at some point. Choose File > Save As and select the standard OpenSpreadsheet .ods format.

Csv6

9. Click Save.

Saving a Calc Spreadsheets as a .txt or .csv File

1. Let's say it's the other way around—you've got a spreadsheet and you want it to be in a nice neutral .txt or .csv file. Be sure the file is open.

2. Choose File > Save As and select the same Text CSV format in the file format list. This time you can click T just once.
Csvsaveas

3. Click Save.

4. You'll probably see this message. Click Yes.

Saveas1

5. In the next window, specify the type of character you want to separate columns, commas or tabs or another character.
Saveas2_1

6. Click OK; you're done.