Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Export string with quote as delimited

    I am puzzled about -export delimited- with the option quote. It does not export a string as I expect it. Stata adds quote to already existing quotes inside a string.
    The data example is a follows:

    Code:
    cwf default
    frame create test
    cwf test
    clear
    input str95 identifiers
    `"ROR:"https://ror.org/0003e4m70""'                                     
    `"ROR:"https://ror.org/0008wzh48""'                                     
    `"ROR:"https://ror.org/0008xqs48""'                                     
    `"ROR:"https://ror.org/000917t60""'                                     
    `"ROR:"https://ror.org/0009t4v78";ETER:"UK0001""'                       
    `"ROR:"https://ror.org/000a1tn51""'                                     
    `"ROR:"https://ror.org/000aqgk72";GERiT:"260878041""'                   
    `"ROR:"https://ror.org/000bxzc63";GERiT:"10085""'                       
    `"ROR:"https://ror.org/000cyem11";CORDIS:"999558714";HHUMACH:"1021949""'
    `"ROR:"https://ror.org/000e0be47""'                                     
    `"ROR:"https://ror.org/000h6jb29";GERiT:"10394""'                       
    `"ROR:"https://ror.org/000hdh770";ETER:"SE0024""'                       
    `"ROR:"https://ror.org/000nhpy59""'                                     
    `"ROR:"https://ror.org/000p86k36";GERiT:"269434572""'                   
    `"ROR:"https://ror.org/000prga03""'                                     
    `"ROR:"https://ror.org/000q08p21";CORDIS:"996684604""'                  
    `"ROR:"https://ror.org/000rdbk18";GERiT:"244850363""'                   
    `"ROR:"https://ror.org/0011qv509""'                                     
    `"ROR:"https://ror.org/0013shd50";CORDIS:"954214318""'                  
    `"ROR:"https://ror.org/0015ws592";HHUMACH:"1012361""'                   
    end
    
    local export_csv `"delimiter(";") datafmt quote replace nolabel"'
    local data_extorga "Test_OrgData"
    
    export delimited using `data_extorga'.csv, `export_csv'
    I expect the data in the csv-file as above:
    "ROR:"https://ror.org/0003e4m70""'
    But the export is:
    "ROR:""https://ror.org/0003e4m70"""

    Is there a way to change this behaviour?

  • #2
    You seem to want an extra set of double quotes. The compound double quotes simply allow for the inclusion of quotes within strings.

    Code:
    replace identifiers= `"""' + identifiers + `"""'

    Comment


    • #3
      Andrew Musau Thank you for your quick reply.

      I got feedback from someone who said that this csv-file has a wrong format. So I wanted to correct it without thinking about it too much... But the person is wrong in his judgement. Stata is doing it correctly. I need the double quotes around double quotes....

      Comment

      Working...
      X