0

I'm running into issues loading a file that doesn't consistently encapsulate address fields.

For example, an XLSX file has the following data (the {tab} represents an actual tab character):

Name Address_1 Address_2
Mary 123 St. Apt A
Joe 123 St. Apt, B
David 123 St. Apt{tab}C

When saved as CSV and opened in notepad, the result is:

Name,Address_1,Address_2  
Mary,123 St.,Apt A  
Joe,123 St.,"Apt, B"  
David,123 St.,"Apt{tab}C"

Per this SO post, it is apparently not possible to load this as is. Either none of the values in a single field are encapsulated or all of them must be.

What methods are there to save this XLSX as a CSV and enforce encapsulation?

PowerUser
  • 11,583
  • 20
  • 64
  • 98
  • What do you mean by **load this**? I have no problem either opening or importing it into Excel (or Power Query) as is, with only some fields being quoted. You've only tagged `excel`, `csv`, `export-to-csv`. If you need to quote **all** fields to use in a different program, you can write a VBA routine to format the file as you wish. Look at [Procedure to export a text file with both comma and quote delimiters in Excel](https://learn.microsoft.com/en-US/office/troubleshoot/excel/export-text-file-with-comma-quote). – Ron Rosenfeld Apr 15 '23 at 01:20
  • There is further discussion of this with additional methods on SuperUser: [How do you force excel to quote all columns of a CSV file?](https://superuser.com/questions/130592/how-do-you-force-excel-to-quote-all-columns-of-a-csv-file) – Ron Rosenfeld Apr 15 '23 at 01:27

0 Answers0