Book a Demo

Author Topic: Problems with „Search in Model“ containing notes when exporting to CSV  (Read 8002 times)

PeterHeintz

  • EA Practitioner
  • ***
  • Posts: 1001
  • Karma: +59/-18
    • View Profile
I created a SQL search query. What I need from that query is a CSV file export.

Due to the fact that I need the notes of my elements, I defined “Note as Notes” to get rid of that “special treatment of the note field”. But there is another “special treatment of the note field” when it contains some text formatting stuff like Bold, List, … . In this case those parts of the note filed are not going in my notes column when exporting to CSV, but in one to many additional rows below the element.
Does anyone know a way to get rid of this “special treatment of the note field”?
Best regards,

Peter Heintz

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
I don't see how you can export notes fields into a CSV file. How are you going to handle newlines? Try to find a solution where you don't need the notes.

If that is not possible you'll have to invent a SQL based solution using the string functions available in the database you are using.

Geert

PS. Or build the export as a script or add-in of course

PeterHeintz

  • EA Practitioner
  • ***
  • Posts: 1001
  • Karma: +59/-18
    • View Profile
Thank you!
I will try the DB string functions way. At the end the data will be imported into a "black whole" so newlines is not an issue for me.
Best regards,

Peter Heintz

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
The RFC handles this. Strings with special chars need to be double quoted and quotes need to be escaped. This way you can have anything inside a CSV element. Unfortunately everyone (including Sparx and especially Mickeysoft) have ignored the RFC and implemented their own flavor (which of course only exchanges data in few circumstances).

q.

Glassboy

  • EA Practitioner
  • ***
  • Posts: 1367
  • Karma: +112/-75
    • View Profile
The RFC handles this. Strings with special chars need to be double quoted and quotes need to be escaped. This way you can have anything inside a CSV element. Unfortunately everyone (including Sparx and especially Mickeysoft) have ignored the RFC and implemented their own flavor (which of course only exchanges data in few circumstances).

Plus those sneaky smart quotes getting into everything.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Escaping them is simply by duplicating them. A string starting with a double quote ends with a not-doubled double quote. You just need a LR1 parser (that's one chat look-ahead). Strings starting with a non-blank end with the last non-blank before a separator. The separator is chosen by negotiation and can be a comma (hence the name CSV), a semi-colon, a tab-char, or anything else (but that's rarely the case).

Sparx especially does not know that when using a semi-colon as separator and having that char as part of a string, the string must be quoted (at least I remember this from a former EA version; not using any build-in exporter any more and doing that by myself...).

q.
« Last Edit: August 09, 2016, 07:48:24 am by qwerty »

je-van

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
    • View Profile
Hello All - The Notes field is one of the key parts of my model search report, which I would like to export to CSV.

It appears this problem has not been solved because I have the same issue mentioned in earlier posts by PeterHeintz ("In this case those parts of the note filed are not going in my notes column when exporting to CSV, but in one to many additional rows below the element"). I also have new lines in the Notes field.

Any info on the status of this issue? I haven't found anything so far.

Thanks.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
I just recently noticed that, in 14.1.1427 the CSV export has been fixed.
If a field contains newlines then it is enclosed in double quotes as it should.

Geert