![]() |
Add double quotes to each field
HI all, Not sure if this is the correct forum for this question, feel free t move it if not. My issue is I have made an excel sheet that contains 500 rows and 1 columns. I need to export this as a CSV but when exproting, each field MUST b delimited by double quotes ex: "data" When taving either as a CSV or tab delimited text, it does not put th quotes in. How can I do this? The data must be formated as such: "product_sku2","product_s_desc","product_desc","TN _pic2.jpg","pic2.jpg","","","","","","","7","","N" ,"","Produc Name2","87.78","category/level1/level2|category2/level1/level2","1" Thank you in advance for any help provided -- npereir ----------------------------------------------------------------------- npereira's Profile: http://www.excelforum.com/member.php...fo&userid=1079 View this thread: http://www.excelforum.com/showthread.php?threadid=47537 |
Add double quotes to each field
Anyone know how to do this -- npereir ----------------------------------------------------------------------- npereira's Profile: http://www.excelforum.com/member.php...fo&userid=1079 View this thread: http://www.excelforum.com/showthread.php?threadid=47537 |
Add double quotes to each field
One way: I assume your data is in A1:S500. In T1, enter this formula: =CONCATENATE("""",A1,"""") NOTE: that is 4 double quotes i succession, A1, then 4 more dble quotes. Copy this to the right 19 columns, then copy all 19 cells (T:AL) dow the 500 rows. Now, all of your entries should be replicated, surrounded in doubl quotes. At this point you could delete columns A:S and then proces your export. Does this work for you -- swatsp0 ----------------------------------------------------------------------- swatsp0p's Profile: http://www.excelforum.com/member.php...fo&userid=1510 View this thread: http://www.excelforum.com/showthread.php?threadid=47537 |
Add double quotes to each field
If you feel comfortable with VBA, select the cells you want to process and run:
Sub Macro1() Dim r As Range For Each r In Selection r.Value = Chr(34) & r.Value & Chr(34) Next End Sub -- Gary's Student "swatsp0p" wrote: One way: I assume your data is in A1:S500. In T1, enter this formula: =CONCATENATE("""",A1,"""") NOTE: that is 4 double quotes in succession, A1, then 4 more dble quotes. Copy this to the right 19 columns, then copy all 19 cells (T:AL) down the 500 rows. Now, all of your entries should be replicated, surrounded in double quotes. At this point you could delete columns A:S and then process your export. Does this work for you? -- swatsp0p ------------------------------------------------------------------------ swatsp0p's Profile: http://www.excelforum.com/member.php...o&userid=15101 View this thread: http://www.excelforum.com/showthread...hreadid=475371 |
Add double quotes to each field
does not seem to work correctly as after exporting to CSV, the CSV file shows this: """1805""","""plastex/mini-kit.jpg""","""Mini Master Kit""","""""" There are 3 Double quotes when there should only be 1 -- npereira ------------------------------------------------------------------------ npereira's Profile: http://www.excelforum.com/member.php...o&userid=10799 View this thread: http://www.excelforum.com/showthread...hreadid=475371 |
Add double quotes to each field
Don't know how to do this with a simple "Save As..." or anything, but you
could build the output file yourself with code: Public Sub CSVOut(DataRange as Range) Dim RowCount as Integer, ThisRow as Integer Dim ColCount as Integer, ThisCol as Integer Dim CSVString as String ' Determine number of rows and columns RowCount = DataRange.Rows.Count ColCount = DataRange.Columns.Count ' Open file to write text output: Open "C:\CSVOutFile.csv" for Output as #1 For ThisRow = 1 to RowCount ' Loop through rows CSVString = "" ' reset the output string For ThisCol = 1 To ColCount ' Loop through columns and build the string for a new line ' Get cell value and append it to the string with quotes ("): ' (Note: if this is the first column we do not need a comma, otherwise we do) If ThisCol < 1 Then CSVString = CSVString & "," CSVString = CSVSTring & """ & DataRange.Cells(ThisRow,ThisCol).Text & """ Next ThisCol ' end of column 'Write the line of csv data to the text file: Print #1, CSVString Next ThisRow Close #1 End Sub -- - K Dales "npereira" wrote: HI all, Not sure if this is the correct forum for this question, feel free to move it if not. My issue is I have made an excel sheet that contains 500 rows and 19 columns. I need to export this as a CSV but when exproting, each field MUST be delimited by double quotes ex: "data" When taving either as a CSV or tab delimited text, it does not put the quotes in. How can I do this? The data must be formated as such: "product_sku2","product_s_desc","product_desc","TN _pic2.jpg","pic2.jpg","","","","","","","7","","N" ,"","Product Name2","87.78","category/level1/level2|category2/level1/level2","1" Thank you in advance for any help provided. -- npereira ------------------------------------------------------------------------ npereira's Profile: http://www.excelforum.com/member.php...o&userid=10799 View this thread: http://www.excelforum.com/showthread...hreadid=475371 |
Add double quotes to each field
Odd, if there are only single quotes <before you export, that you would end up with <triple quotes after. Are you sure you need to add the quotes before the export? Maybe try this: Copy the range with the formulas, then Paste SpecialValues to remove the formulas and end up with just the plain text entry e.g.: "data". Then export. Any change? -- swatsp0p ------------------------------------------------------------------------ swatsp0p's Profile: http://www.excelforum.com/member.php...o&userid=15101 View this thread: http://www.excelforum.com/showthread...hreadid=475371 |
Add double quotes to each field
putting your data inside double quotes within the worksheet is a
non-starter. When you export it, Excel will delimit the existing double quotes with double quotes and enclose the entry in double quotes. This is expected behavior - no mystery. This is what it has to do to reproduce what you have in the sheet, so the changes should not be made in the sheet. See K Dales' suggestion or look at this article: http://support.microsoft.com/default...b;en-us;291296 Procedure to export a text file with both comma and quote delimiters in -- Regards, Tom Ogilvy "swatsp0p" wrote in message ... Odd, if there are only single quotes <before you export, that you would end up with <triple quotes after. Are you sure you need to add the quotes before the export? Maybe try this: Copy the range with the formulas, then Paste SpecialValues to remove the formulas and end up with just the plain text entry e.g.: "data". Then export. Any change? -- swatsp0p ------------------------------------------------------------------------ swatsp0p's Profile: http://www.excelforum.com/member.php...o&userid=15101 View this thread: http://www.excelforum.com/showthread...hreadid=475371 |
Add double quotes to each field
Tom Ogilvy Wrote: See K Dales' suggestion or look at this article: http://support.microsoft.com/default...b;en-us;291296 Procedure to export a text file with both comma and quote delimiters in Excellent, this worked like a charm... Thanks -- npereira ------------------------------------------------------------------------ npereira's Profile: http://www.excelforum.com/member.php...o&userid=10799 View this thread: http://www.excelforum.com/showthread...hreadid=475371 |
All times are GMT +1. The time now is 10:50 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com