Book a Demo

Author Topic: Export to CSV in specific order  (Read 3767 times)

elgringogordo

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Export to CSV in specific order
« on: October 25, 2018, 07:11:08 pm »
I have a simple model which is currently just a 3 level hierarchy (4 if you include the root package!).  The top level are packages and the next 2 levels are Requirement elements.  So

    Epic 1 (Package)  ->
            US 1 (Requirement) ->
                UC 1 (Requirement)   
                UC 2 (Requirement)   
                UC 3 (Requirement)   
            US 2 (Requirement) ->
                ...

            US 3 (Requirement) ->
                ...
Epic 2 (Package)
            US 10 (Requirement) ->
                ...


Epic 3 (Package)
            US 12 (Requirement) ->
                ...

I'm playing with exporting this to csv and I can't seem to get the csv to export in the same order as the model.

If I check 'Preserve Hierarchy' in the spec I get CSV_KEY & CSV_PARENT_KEY which are obviously useful for me to do various things with myself but the csv itself is a list of level 1, followed by a list of level 2, followed by a list of level 3.  To be honest I'm not entirely sire of the final requirement for my csv file yet but at a minimum it will be the hierarchy (probably with more levels added) to be listed in order.

Apologies this is a roundabout waffly question but I'm thinking now it will be best to write a csv export vba macro (I have already written an importer) rather than fiddle around with the csv file.  I guess the main question is am I missing a chunk of EA functionality around export to csv which would make this unnecessary.  As a supplementary question any suggestions for the best approach (i.e. do you agree vba is the simplest approach to creating a flexible & repeatable export to csv facility).

Thanks!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Export to CSV in specific order
« Reply #1 on: October 25, 2018, 07:17:00 pm »
I don't use the CSV export (because it's easier for me to script it in case I need it). You should take a look into the CSV export scripts that come along with the EAScriptLib which can be adapted quite easily. Or you take a look into Geert's export script.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Export to CSV in specific order
« Reply #2 on: October 25, 2018, 07:18:27 pm »
I would write an SQL search query (where I control the order) and then export the results to CSV.
No scripting needed.

If however you need notes fields with newlines etc.. you might want to consider scripting somehow.
I have done a few exports like that to Excel directly, including formatting in excel.

Geert


elgringogordo

  • EA Novice
  • *
  • Posts: 10
  • Karma: +0/-0
    • View Profile
Re: Export to CSV in specific order
« Reply #3 on: October 25, 2018, 08:39:15 pm »
Okay thanks,

I hadn't seen the SQL query functionality before and after 1/2 an hour I don't feel much more confident, but I do feel 50% more stupid as I'm struggling to grasp it a bit.  I'll write a quick basic VBA export so I have somethign should anyone need it and then get back to mastering EA a bit better.

Thanks again.