+ Reply to Thread
Results 1 to 20 of 20

.CSV format problem

  1. #1
    Registered User
    Join Date
    01-30-2014
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    9

    .CSV format problem

    Hi - I need to save an Excel spreadsheet in .csv format so that when its opened in Notepad the fields appear with "Quotation Marks" around the data.

    Like this:

    "H","203107/X5269243","Amazon .co.uk"," ","Phace Two","Kingston Park","Flaxley Road","Peterborough Cambridge","PE2 9EN"," "," "," "," "," "," ",
    "D",6.00,"SB2601",
    "D",6.00,"10021J",
    "D",6.00,"NSERUM",

    It's for orders that my warehouse need to import into their system and I can't seem to get the "Quotation Marks" around the data. Even the fields with no data require empty quotation marks.

    Can you anyone help!

    Many thanks,

    Graham

  2. #2
    Forum Contributor codeslizer's Avatar
    Join Date
    05-28-2013
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003 - 2010
    Posts
    245

    Re: .CSV format problem

    Hello Graham, Very warm welcome to the Forum.

    As I've tried, I believe there is no direct solution but I do have a workaround. For that, we'll have to first wrap the values inside each filled rows with double quotes like "6.00" and even the empty fields till the columns the data should be - followed by saving it in CSV format (DOS) so that you can open it in Windows. After that, we'll have to create a FileSystem object and open the newly created CSV file and iterate through each row in the file and replace triple quotes (""") with single quotes ("). Why? - Coz when you save the file in CSV with double quotes wrapping up the values, you'd find the three quotes in it when you open it in Notepad.

    Would you be able to upload a sample file containing the no critical data. It would help me understand the structure of your file. Basically, how many columns will be used.
    Last edited by codeslizer; 01-30-2014 at 08:17 AM.
    cOdEsLiZeR - Back after a long break.. Let's sLiZe some more cOdEs!!

  3. #3
    Registered User
    Join Date
    01-30-2014
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: .CSV format problem

    Thanks for the welcome and the assistance!

    Please see a sample file enclosed.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    01-28-2014
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: .CSV format problem

    Graham...Not sure if this will do it. It works for me in certain cases. Try formatting your cells with Custom \"@\" Once you have done that you should be able to type text into these cells and the quotation marks will be included.

  5. #5
    Registered User
    Join Date
    01-28-2014
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: .CSV format problem

    Graham. Looks like this format can be used. After you have populated the sheet, you will need to run a macro like shown below to help replace the triple quotation marks with the single ones.
    Sub SaveAsCSV()

    Dim SrcRg As Range
    Dim CurrRow As Range
    Dim CurrCell As Range
    Dim CurrTextStr As String
    Dim ListSep As String
    Dim FName As Variant
    FName = Application.GetSaveAsFilename("", "CSV File (*.csv), *.csv")

    If FName <> False Then
    ListSep = Application.International(xlListSeparator)
    If Selection.Cells.Count > 1 Then
    Set SrcRg = Selection
    Else
    Set SrcRg = ActiveSheet.UsedRange
    End If
    Open FName For Output As #1
    For Each CurrRow In SrcRg.Rows
    CurrTextStr = ""
    For Each CurrCell In CurrRow.Cells
    CurrTextStr = CurrTextStr & """" & CurrCell.Value & """" & ListSep
    Next
    While Right(CurrTextStr, 1) = ListSep
    CurrTextStr = Left(CurrTextStr, Len(CurrTextStr) - 1)
    Wend
    Print #1, CurrTextStr
    Next
    Close #1
    End If
    End Sub

  6. #6
    Forum Contributor codeslizer's Avatar
    Join Date
    05-28-2013
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003 - 2010
    Posts
    245

    Re: .CSV format problem

    A few queries that I've :

    1. Will numeric values have double quotes around them as well?
    2. And do you want even the blanks to be wrapped around with quotes? Or maybe its just entries with 'space' that you want to see within quotes.

    There are some cells with blanks that are not getting wrapped with quotes especially the ones with no entries, rest spaces are getting within the quotes. See attached.
    Last edited by codeslizer; 01-30-2014 at 09:35 AM.

  7. #7
    Registered User
    Join Date
    01-28-2014
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: .CSV format problem

    If you are needing quotation marks around numbers for some fields, then use a format for those columns like \"###.###\" or \"##.##\"

  8. #8
    Forum Contributor codeslizer's Avatar
    Join Date
    05-28-2013
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003 - 2010
    Posts
    245

    Re: .CSV format problem

    I believe dsqrdman has already got the solution.

  9. #9
    Registered User
    Join Date
    01-30-2014
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: .CSV format problem

    Thanks guys - how do I insert this format into the columns? Sorry, really basic knowledge of Excel!

  10. #10
    Registered User
    Join Date
    01-28-2014
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: .CSV format problem

    Your welcome...please select the column or range of cells and then use the custom format option in Excel... Please refer to your many resources online for custom Excel formatting...http://www.ozgrid.com/Excel/excel-cu...er-formats.htm

  11. #11
    Registered User
    Join Date
    01-30-2014
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: .CSV format problem

    Still can't get it to work. I custom format the cells in the spreadsheet, save as a csv, but still no. When viewed in notepad I don't see the quotation marks...

  12. #12
    Registered User
    Join Date
    01-28-2014
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: .CSV format problem

    Would you be able to upload your most recent sample file containing the no critical data?

  13. #13
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: .CSV format problem

    I downloaded your file and saved it as a CSV. Then I opened the file in Word and did a Search and Replace for Commas, searching for commas and replacing with "," . The next step was to search for the paragraph mark and replace with ^p". This had the effect of placing the " in front of the next record. (all records will end with the paragraph mark. The final step was to manually place a " at the beginning of the data.

    The result is:

    “H”,”27.01.14”,”Duhamel Logistique”,”Parc Affaires Des Portes”,”Voie Du Futur”,”MenCorner-RINKA”,”Val De Reuil”,”“,”27100”,” “,” “,” “,” “,” “,” “,”“,”FRANCE”
    “D”,”30”,”GT1500”,”“,”“,”“,”“,”“,”“,”“,”“,”“,”“,”“,”“,”“,”
    “D”,”12”,”GT1501”,”“,”“,”“,”“,”“,”“,”“,”“,”“,”“,”“,”“,”“,”
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  14. #14
    Registered User
    Join Date
    01-30-2014
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: .CSV format problem

    Latest excel file and csv file enclosed. Perhaps its the way I am saving the excel file?
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    01-28-2014
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: .CSV format problem

    Please see the attached files
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    01-28-2014
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: .CSV format problem

    You will need to run the macro in the QuoteFormat file to create the .csv file. Once you have the .csv file, make a copy of it and see if you can rename the file extension from .csv to .txt and view it the text file in notepad or another text editor app.

  17. #17
    Registered User
    Join Date
    01-30-2014
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: .CSV format problem

    How do I 'Run the Macro' in the QuoteFormat file?

  18. #18
    Registered User
    Join Date
    01-28-2014
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: .CSV format problem

    Please see the following links for macro instructions for Excel 2003:

    http://office.microsoft.com/en-us/ex...005202306.aspx

    http://office.microsoft.com/en-us/ex...001119579.aspx

    You should be able to see the macro named SaveAsCSV, select it, and run it.

  19. #19
    Registered User
    Join Date
    12-03-2013
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: .CSV format problem

    Requiring "quotes" in the file vs a simple comma delimited line seems odd. By chance, have you tried having a plain comma limited file (.csv) uploaded to your system?

  20. #20
    Registered User
    Join Date
    01-30-2014
    Location
    London
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: .CSV format problem

    Just a quick thank you - this is now working and my warehouse are importing my orders directly - thank you very much!

    Graham

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. format Problem
    By mohan.r1980 in forum Excel General
    Replies: 1
    Last Post: 11-17-2010, 08:35 AM
  2. Format problem
    By wwoody in forum Excel General
    Replies: 3
    Last Post: 03-12-2008, 04:56 PM
  3. Format-Having a problem with a format column.
    By Bob W in forum Excel General
    Replies: 2
    Last Post: 01-23-2008, 05:54 PM
  4. [SOLVED] Format Problem
    By Amjad in forum Excel General
    Replies: 1
    Last Post: 09-12-2005, 06:05 AM
  5. Problem with txt format
    By Nuno in forum Excel General
    Replies: 2
    Last Post: 01-18-2005, 01:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1