JArchi Scripting: Export to CSV

Update: 08/06/2022

I’ve updated the script as hosted on GitHub Gists to now support Specializations.

The JArchi scripting plugin for Archi opened up some interesting possibilities for getting data in and out of an Archi model. The standard Archi export to CSV allows you to export an entire model to CSV. It creates three CSV files, one for elements, one for relationships and one for properties. To recombine these files, you need to import them into a spreadsheet or database, and join or lookup the values based on the unique keys.

I needed an export function which would allow me to export all elements within a given view, exporting the standard attributes and custom properties as headers. After putting my Export to Markdown script together, I felt like I could try and take a crack at putting this together in JArchi, with the hope that once I managed to export to data, I could update the values in a spreadsheet, and re-import the data (spoiler alert, Import from CSV is here, I’ll put a more detailed post together soon).

The jArchi script to Export to CSV is available on GitHub Gists.

This script requires PapaParse. Download the papaparse package, and extract the papaparse.min.js script into a “lib” folder in the same location as the Export to CSV.ajs script in your jArchi script folder.

This script will:

  • Define the standard headers (Name, Documentation, UID, Type)
  • Loop through all elements contained in the view.
    • Note all properties
    • Extract all relationships
  • Use PapaParse to write all elements and properties to CSV
  • Use PapaParse to write all relationships to CSV

Example Output

Relationship ID From Name From Type Relationship Type To Name To Type Relationship Name Relationship Documentation
611228f0-c06c-4ffc-9145-7f7091113cf4 [archi] jArchi Plugin application-function influence-relationship Support Archi on Patreon requirement
b03b0ef5-9085-4204-9cc0-b8456cca1d46 [archi] jArchi Plugin application-function Comprises [archi] Export to CSV application-function
5f24cdf4-66a6-4541-926e-2fcb7a08ce3c jArchi Plugin <<Software>> artifact Realises [archi] jArchi Plugin application-function
937991e2-2221-4e8a-bf5b-a277d598678d Documentation <<Folder>> artifact Comprises Export to CSV.csv <<CSV>> artifact
c334768f-c847-45cb-ab95-78c1bccc8966 Documentation <<Folder>> artifact Comprises Export to CSV-relationship.csv <<CSV>> artifact
5d8206f6-8ec3-409a-bf50-6db0e5fa59b7 [archi] Archi 4.3.3 application-component Assigned to [archi] jArchi Plugin application-function Plugin
9c3dfe66-0b79-4da8-89d6-82111c8b5a8a [archi] Archi 4.3.3 application-component Serves/Used By Develop Enterprise Architecture Model business-process
e7a07bca-c65f-42b2-81dd-16e6ed03e724 Desktop Computer device Assigned to Archi 4.3.3 <<Software>> artifact
0909bf75-8983-40d7-be3f-dc536e07cc24 Desktop Computer device Assigned to jArchi Plugin <<Software>> artifact
3313b7c2-b4fa-4389-859b-a8162e55fa17 Desktop Computer device Assigned to Documentation <<Folder>> artifact
95898360-62d3-44aa-8f2e-f24c4666c42e Desktop Computer device Assigned to Export to CSV.ajs <<Script>> artifact
f737c607-0bb4-4760-a492-9d979854ebbe Desktop Computer device Assigned to MS Excel <<Software>> artifact
f995ace5-809e-4d93-92f6-10807909daca Desktop Computer device Assigned to papaparse.min.js <<Script>> artifact
27eea169-ef4e-425e-8477-ee2dd71b6002 Archi 4.3.3 <<Software>> artifact Realises [archi] Archi 4.3.3 application-component
79554dcd-502d-4ce7-8aaf-99887127cc74 [archi] Export to CSV application-function Accesses Export to CSV.csv <<CSV>> artifact
264b3e5e-563d-49d8-9ccd-0a4f87125e8d [archi] Export to CSV application-function Accesses Export to CSV-relationship.csv <<CSV>> artifact
0da87b2f-28cc-4312-a60c-6d1f51b6a7c4 [archi] Export to CSV application-function influence-relationship Maintain archimate properties in spreadsheet goal
fb173524-5698-4df7-a7f7-162d14e153ae Export to CSV.ajs <<Script>> artifact diagram-model-connection diagram-model-note
cc246b55-09ad-4455-9184-0a5274fc09e9 Export to CSV.ajs <<Script>> artifact Realises Junction junction
d52559c4-da2b-4c77-a039-057500dfbe35 MS Excel <<Software>> artifact Realises Microsoft Excel application-component
288f5e29-6b3e-445b-88cc-2cefa0479e3b Microsoft Excel application-component Accesses Export to CSV.csv <<CSV>> artifact
df3132ff-9da8-40e2-9551-9ef91a11d225 Microsoft Excel application-component Accesses Export to CSV-relationship.csv <<CSV>> artifact
13e69a99-17a4-4801-b1d0-cf9b57b3a087 papaparse.min.js <<Script>> artifact Realises Junction junction
d4a9635d-8c2d-4873-8ca1-093c73a72a7d Junction junction Realises [archi] Export to CSV application-function
Name Documentation UID Type Website Licence
[archi] jArchi Plugin jArchi is a JavaScript-based scripting plug-in built on the [Nashorn](https://www.oracle.com/technetwork/articles/java/jf14-nashorn-2126515.html) engine. This means that the end-user can write code, or simple scripts, using JavaScript, and this is then translated into the underlying Java code that drives Archi. 873d48ae-092f-4110-a6a6-e501c98fad45 application-function https://www.archimatetool.com/blog/2018/07/02/jarchi/ Open Source (HUMANS)
jArchi Plugin <<Software>> C:\Program Files\Archi4\plugins\com.archimatetool.script.commandline_0.4.3.201902121146.jar C:\Program Files\Archi4\plugins\com.archimatetool.script.premium_0.4.1.201902121146.jar C:\Program Files\Archi4\plugins\com.archimatetool.script_0.4.3.201902121146.jar 00b42401-1bf5-4f40-9409-07f641cdc43e artifact
Support Archi on Patreon Only supporters of [ArchiTool on Patreon](https://www.patreon.com/architool/overview) can access the binary download of the jArchi plugin (as well as other exclusive content) 5b377dce-3eef-4881-9baa-919c72b60b5a requirement
Documentation <<Folder>> Local folder to store EA documentation. a5ac0486-a672-4f19-84f8-45f158ae2519 artifact
Export to CSV.csv <<CSV>> All elements contained in the Export to CSV view in CSV format (including custom properties) d78d7320-5445-4ba8-8180-b7712835caf9 artifact
Export to CSV-relationship.csv <<CSV>> All relationships contained in the Export to CSV view in CSV format (including custom properties) 72d53cb8-af37-4ee2-a011-d3e2ca74b9b0 artifact
Develop Enterprise Architecture Model 429611cf-719c-4cc4-8f46-13ca3279ca7c business-process
[archi] Archi 4.3.3 Archi fulfils the needs of most Enterprise Architects and associated stakeholders, and has been designed to elegantly provide the main features required for ArchiMate modelling and is used globally by banks, insurance companies, industry, EA consultants, training organisations, universities, and students. It is the world’s most popular ArchiMate modelling tool and is downloaded between two and three thousand times every month. 87305cf3-48eb-4145-806a-9274f50d870a application-component https://www.archimatetool.com/ Open Source (MIT)
Desktop Computer > A device is a physical IT resource upon which system software and artifacts may be stored or deployed for execution. > — [ArchiMate 3](http://pubs.opengroup.org/architecture/archimate3-doc/chap10.html#_Toc489946085) Smileham: The usage of ArchiMate and Archi models should be derived from the questions that you want to answer. When I first began modelling, I wanted to seperate the logical server (node) from the physical or virtual server (device) on which they were executing. This seperation allows an architect to query the model to find where all particular makes/models/configurations of physical devices are used in the architecture. 683b4d3e-d681-42ef-b45a-e71819bdba41 device
Archi 4.3.3 <<Software>> C:\Program Files\Archi4 cf786259-43f3-4c29-a6f4-0e2923ebdb9c artifact
[archi] Export to CSV 313a437e-fd94-429f-a565-7e513cb6edf5 application-function https://gist.github.com/smileham/15c445b17a92bd6f5dc1508e573bcd8a Open Source
Export to CSV.ajs <<Script>> C:\Users\steve\AppData\Roaming\Archi4\scripts\Import-Export\Export to CSV.ajs b0fad396-72fc-4d77-af08-ac66505049ce artifact
MS Excel <<Software>> C:\Program Files\MSOffice\Excel 3d9cb13a-83e8-4951-8982-54d2aa9f5ee3 artifact
Microsoft Excel Microsoft Excel is a spreadsheet developed by Microsoft for Windows, macOS, Android and iOS. It features calculation, graphing tools, pivot tables, and a macro programming language called Visual Basic for Applications. It has been a very widely applied spreadsheet for these platforms, especially since version 5 in 1993, and it has replaced Lotus 1-2-3 as the industry standard for spreadsheets. Excel forms part of the Microsoft Office suite of software. b23da5c6-fca5-4d9b-aad4-6d9cda03fdb0 application-component https://products.office.com/en-gb/excel MS Office 365 Licence
Maintain archimate properties in spreadsheet 43238f96-b3bf-4cbd-a53b-009595272c29 goal
papaparse.min.js <<Script>> Papa Parse is the fastest in-browser CSV (or delimited text) parser for JavaScript. It is reliable and correct according to RFC 4180. 00e2c5a3-415d-4599-982e-6e0e1627fb64 artifact https://www.papaparse.com/ Open Source (MIT)
Junction e4ba57bf-9a9a-4dcb-bb18-8ada07ad5e1d junction

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.