Problem saving Excel as text file

  • Thread starter Thread starter Doc Al
  • Start date Start date
  • Tags Tags
    Excel File Text
Click For Summary

Discussion Overview

The discussion revolves around the issue of saving an Excel spreadsheet as a tab-delimited text file, specifically addressing the problem of fields containing commas being enclosed in quotes. Participants explore various methods to prevent this behavior and discuss alternative approaches for transferring data into a SQL Server database.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Experimental/applied

Main Points Raised

  • One participant seeks a method to save an Excel file without quotes around fields containing commas when saved as a tab-delimited text file.
  • Another participant suggests that changing the cell format from Text to General or Custom might resolve the issue with quotes.
  • A participant reports that changing cell formats did not eliminate the quotes, speculating that Excel may be trying to prevent a comma-separated value error.
  • One participant proposes using a text editor for a search and replace method to remove quotes after saving the file, expressing frustration over the inconsistent quoting behavior of Excel.
  • Another participant mentions the possibility of writing a macro to remove quotes from the output, indicating that editing the output is not their preferred solution.
  • Discussion shifts to the database system into which the data is being imported, with one participant sharing their experience of using SQL Server and Access for data import and export.
  • A later reply provides detailed steps on using DTS (Data Transformation Services) in SQL Server for importing Excel data, suggesting it as an alternative to saving as a text file.
  • One participant inquires about the version of Excel being used, noting that their version does not have issues exporting as a tab-delimited text file without quotes.

Areas of Agreement / Disagreement

Participants express differing views on how to handle the quoting issue, with no consensus on a definitive solution. Some propose changing cell formats, while others suggest alternative methods like using a macro or importing directly into SQL Server.

Contextual Notes

Participants mention various Excel versions and their experiences, indicating that the behavior may vary depending on the software version used. There is also a lack of clarity on the underlying reasons for the quoting behavior in Excel.

Who May Find This Useful

This discussion may be useful for users dealing with data export from Excel to text files, particularly those encountering issues with formatting and importing data into SQL databases.

Doc Al
Mentor
Messages
45,583
Reaction score
2,457
I'm trying to save an Excel spreadsheet as a (tab-delimited) text file for input into another database. For some reason, fields containing a comma are being displayed in the text file within quotes, which I don't want. For example:
John Doe appears as: John Doe
Doe, John appears as: "Doe, John"​

What I want to see is:
John Doe appearing as: John Doe
Doe, John appearing as: Doe, John​

Is there any clever way of saving the Excel file so I don't have those quotes?
 
Technology news on Phys.org
I believe the quotes will go away if the cell categories (types) are not Text. Select the cells, then choose Format->Cells.

Can you change the cell type from Text to some other value? Like General or Custom?

- Warren
 
I've tried all sorts of cell formats, but the double quotes still appear for entries that contain a comma. So that didn't work.

(It's almost like the program is trying to prevent a comma-separated value error. But I'm saving as tab-separated text. Strange!)
 
Doc Al said:
I've tried all sorts of cell formats, but the double quotes still appear for entries that contain a comma. So that didn't work.

(It's almost like the program is trying to prevent a comma-separated value error. But I'm saving as tab-separated text. Strange!)

Since you're using Excel, it's clearly not a huge dataset. So you could just use your favorite text editor to do a search and replace to switch quote-tab and tab-quote to tab...

What I personally find obnoxious is that it doesn't quote the other stuff. If it did all or none, it would be a whole lot easier to deal with.
 
NateTG said:
Since you're using Excel, it's clearly not a huge dataset.
About 15K records. Don't ask. :rolleyes:
So you could just use your favorite text editor to do a search and replace to switch quote-tab and tab-quote to tab...
Editing the output, while easy enough, would be my last choice. Good idea, though. (It's just bugging me that I can't turn that stuff off!) But I think I've found how to write a macro that removes the quotes.
 
Doc Al said:
About 15K records. Don't ask. :rolleyes:

Editing the output, while easy enough, would be my last choice. Good idea, though. (It's just bugging me that I can't turn that stuff off!) But I think I've found how to write a macro that removes the quotes.

I know it's ugly, but unless you're going to be doing this sort of thing regularly, the effort in finding the 'nice' answer isn't going to save you any time.
 
Which database system are you moving it into? I usually work with SQL Server and Access so I can just easily import data directly from Excel. I used to have to move around a lot of data, and even if my final format needed to be a delimited text file, I often pulled the data into a database system first, creating a table, and then did the export to text file from there. It gave me a chance to check and clean the data, and also better control of the export process.
 
The Excel data is being moved into a SQL Server table. That's its final destination, for use by another program. (Is there an easy way to move the data directly into SQL Server?)
 
Yes, it's super easy. You can use DTS (Data Transformation Services) in Enterprise Manager. Have you tried out the DTS import wizard?

Here's how you can quickly move an Excel spreadsheet into a new table. In Enterprise Manager, select your database, and then right click and you should see an option for All Tasks and then Import Data. That will bring up the Wizard. Hit next and then make sure you choose Excel for your data source. Then browse to the file you want to import.

Then you hit next and you'll see all the destination info, probably won't need to change anything here, just double check that the target database is correct. Hit next and you'll see an option to just simply copy everything over or you can construct a SQL Query for the transfer.Then hit next and you should get a choice for which worksheets to import. After you have chosen a worksheet, you can edit the name in the path in that destination column to be whatever name you want the new table to have. Hit Next, choose "run immediately" and hit next, check everything over and hit finish.. babdaboom-badabing! You should get a message that it was successful. Refresh Enterprise Manager and you should see your table.
 
Last edited:
  • #10
What version are you using? My Danish 2002 sp3 have no problem exporting as a tab-delimited text file, where Doe, John appears without quotes as needed.
 
  • #11
Math Is Hard said:
Yes, it's super easy. You can use DTS (Data Transformation Services) in Enterprise Manager. Have you tried out the DTS import wizard?
Thanks! I'll check it out.
 

Similar threads

Replies
65
Views
5K
  • · Replies 22 ·
Replies
22
Views
2K
  • · Replies 19 ·
Replies
19
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 20 ·
Replies
20
Views
3K
  • · Replies 4 ·
Replies
4
Views
9K
  • · Replies 3 ·
Replies
3
Views
18K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K