Author Topic: How do I Export Class Attributes in a .csv file?  (Read 4999 times)

TonyC

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
How do I Export Class Attributes in a .csv file?
« on: February 03, 2022, 04:28:31 am »
I can successfully export a package which includes all the element types on the diagrams by using the Export csv function and creating a specification. When I leave the Types field blank, all element types down to Classes are exported.

However, what I need is an export that goes one step deeper. I would like to list all the attributes in every class in a csv so I can import into Excel the list of attributes by class name. Is there a way to do this? Any help would be gratefully received

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13400
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How do I Export Class Attributes in a .csv file?
« Reply #1 on: February 03, 2022, 04:34:54 pm »
You can create an SQL search an then export the results to CSV:

Code: [Select]
select a.ea_guid AS CLASSGUID, 'Attribute' AS CLASSTYPE, o.Name as ClassName, a.Name as AttributeName, a.Type, a.Stereotype, a.Notes
, package.name as PackageName ,package_p1.name as Package_level1,package_p2.name as Package_level2 ,package_p3.name as Package_level3
 from (((((t_attribute a
inner join t_object o on o.Object_ID = a.Object_ID)
inner join t_package package on package.Package_ID = o.Package_ID)
left join t_package package_p1 on package_p1.package_id = package.parent_id)
left join t_package package_p2 on package_p2.package_id = package_p1.parent_id)
left join t_package package_p3 on package_p3.package_id = package_p2.parent_id)
where o.Package_ID in (#Branch#)
and o.Object_type in ('Class', 'Datatype')

Geert
« Last Edit: February 04, 2022, 03:27:07 am by Geert Bellekens »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: How do I Export Class Attributes in a .csv file?
« Reply #2 on: February 03, 2022, 09:51:56 pm »
The problem with SQL results is that the search window will not copy RFC-aware. That is, quoting is rubbish and if you got semicolons in the result you can forget it.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13400
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How do I Export Class Attributes in a .csv file?
« Reply #3 on: February 03, 2022, 10:07:16 pm »
The problem with SQL results is that the search window will not copy RFC-aware. That is, quoting is rubbish and if you got semicolons in the result you can forget it.

q.
They have improved that a lot in recent versions. (if you use the option export to CSV, not sure if that is exactly the same as copy/paste)

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: How do I Export Class Attributes in a .csv file?
« Reply #4 on: February 03, 2022, 10:29:38 pm »
I might look into that once more. That behavior buggered me for so long that I just did not use it any longer...

q.

Richard Freggi

  • EA User
  • **
  • Posts: 493
  • Karma: +18/-7
    • View Profile
Re: How do I Export Class Attributes in a .csv file?
« Reply #5 on: February 03, 2022, 11:13:48 pm »
I just use CTRL-A to select everything directly in the search results window, then paste special into Excel with comma as separator and double quote as text marker.  Seems to work OK even for 3-400K rows * 15 columns of results

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: How do I Export Class Attributes in a .csv file?
« Reply #6 on: February 04, 2022, 04:16:10 am »
It looks like they replaced the separator with a comma. And (oh wonder) they quote text when it contains a comma. And (more wonders) they even dbl-quote a quote when it occurs. Miracles happen eventually.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13400
  • Karma: +566/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How do I Export Class Attributes in a .csv file?
« Reply #7 on: February 04, 2022, 04:41:07 am »
It looks like they replaced the separator with a comma. And (oh wonder) they quote text when it contains a comma. And (more wonders) they even dbl-quote a quote when it occurs. Miracles happen eventually.

q.
Told you it had been improved  ;D

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: How do I Export Class Attributes in a .csv file?
« Reply #8 on: February 04, 2022, 07:19:49 am »
I only trust what I see with my own eyes xD

q.

TonyC

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
Re: How do I Export Class Attributes in a .csv file?
« Reply #9 on: February 09, 2022, 09:56:52 pm »
You can create an SQL search an then export the results to CSV:

Geert

Many thanks Geert, this is precisely what I required and your SQL worked a treat.
Regards,
Tony