-
-
Notifications
You must be signed in to change notification settings - Fork 272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved CSV Import/Export #63
Comments
I've started work on this. I have the Export to CSV working. Most users will be happy with the "," comma delimiter. I can also add the ";" semicolon. I would prefer to limit the delimiters (!) to just these two, or is there another one? Any suggestions for a GUI? I guess It will have to be an extended dialog/wizard like the Export Image one. |
I think comma and semicolon are enough and represent more than 90% of usage. For the GUI I have to think a little bit about it but we'll need a wizard. |
I have a system for file selection.
Where "ab45ed7b" is the id of the model. This allows the user to export more than one model to csv in the same folder. It also links the three files. |
Not sure having id as suffix is a user-friendly thing. Maybe an option (turned off by default) to add a suffix, alongside with a text field (then if checked but empty, use model ID)...
Or just the text field, and then if empty don't put suffix at all (get rid of -) |
I think some kind of suffix is a good idea. Otherwise the user will have to keep selecting a different folder for each model export. It could be the case that the user wishes to export a few models, and would like to keep them in the same folder. I know in my tests I was manually adding a suffix to the three files in order to group them together. Another option is a time-stamp suffix. |
Doing this in two stages, first is Export. Let's get this agreed before moving on to Import. Created (temporary) branch for Export to CSV and tests: |
I've just tested and it works like a charm. I only have 2 remarks:
Anyway, really good job: I was able to import file in LibreOffice without issues (even with descriptions containing newlines). |
|
Re: Import CSV. We need to be clear what the format should be. I don't want to end up writing a CSV parser for all known cases under the sun. ;-) |
Latest export seems perfect. Regarding CSV import, for me there's no real question: the format should be exactly the same as the one used for export so that exporting and then importing leads to the same model content (without views of course). |
I mean things like:
When writing this kind of code, one has to be very defensive - what if this, what if that - and you find that it's never ending. If you know what you are expecting and reject it if it does not conform to the "rules" it becomes easier. |
Ok, I understand and agree. In this case I would suggest to conform to the RFC, so:
I would also suggest to:
|
"csv-export" branch has been merged into the "develop" branch. |
Parsing a CSV file on Import is harder than writing an export routine, so it may be worth taking a look at this - http://commons.apache.org/proper/commons-csv/ |
I have implemented Import from CSV files as a new model. See the "csv-import" branch. Select "Import CSV..." from file menu. Select the file that has the name "elements" in it (could be "elements.csv" or "prefix-elements.csv"). If there is a matching *relations.csv and *properties.csv file these will be parsed as well.
This is not so easy. Undo/Redo commands will have to be created and managed for every attribute change, insertion and deletion. Then there is checking the integrity of IDs, elements and relations and their matching diagram objects to make sure nothing is orphaned. |
I will try it today. Regarding import on a already existing model, I know it's not easy and this raise several questions. A usual this was more a mid/long term target. In fact, this leads me to potential generic comparison/merge feature that could be implemented with EMF Diff/Merge (when I will master it, which is not for today). |
I've just tested and here are some remarks:
|
No, because it's like when you create a "new" model. There are no undoable actions yet to mark it as "dirty". Dirty is calculated from at least one command on the command stack. In order to mark it as dirty then all the elements would have to be added as one Command and executed. It's really like doing a "new model" or like "open model". But that's a problem if you just want to save it...hmm...it gets ever more complicated. :-( |
That's not a big deal, as if I close it just after import, then I can easily re-import it again. |
New commit in "csv-import" branch. I've taken a new approach to this because I wanted to solve the following issues:
So...
This approach makes more sense for an "Import" action. The previous way of doing it was more like an "Open As.." action. |
Hi, I did some tests and...
I checked the code and I think the CSVParseException should be caught in several methods into CSVImporter so that an already existing element doesn't stop the import (maybe a choice through an option: "strict/relaxed" ?). Here the use case could be:
Obviously this raise some questions:
Remark: when this will work, we'll then have a solution to sync to/from a CMDB (or any other referential able to export/import CSV)... |
I wanted the user to know about this in case it was a mistake on their part, and not silently fail without them knowing. There's a danger of overloading the functionality on this. We don't want to turn it into a poor man's batch editor. I would like it to be seen as a way of getting content into a model rather than in-out editing and merging... |
My goals:
You are right with the problems of updating Properties. |
I understand and share your goals, but I still think that offering a "relaxed" option (so update/insert instead of insert only) would allow great use cases. For example, I have a big model which contains almost all my servers / application (and business processes in the near futur). I frequently have to check it against my CMDB and this is very difficult. There are also some basic information that I don't want to key in manually (#CPU/RAM, #users...). With a "relaxed" mode, it would be easier for me to update properties. I agree this can be seen as a poors man batch editor, but the goal is still to insert information (properties in my case), not to do a Find/Replace. From a UI perspective, I agree we should avoid too many dialog options. Would it be possible instead to have two menu entries:
Of course, there's maybe another, better, way of offering this feature to end-user... |
If I had to choose, I would go for an import dialog box. Two menu items? JB, I thought you had good taste! ;-) It is possible to do a default update for an element/relation without needing an option:
If update is supported, now I know what you will ask next....ability to read in just the properties files or just the relations file without the elements file. |
"Two menu items? JB, I thought you had good taste! ;-)" Yes I have, I opened a good Bordeaux yesterday ;-) "Not sure how to handle the comparison of Properties because, as you say, it's possible to have more than one key." Obvioulsy the only way is to create a new property only if it does not exist, and update the first match in all other cases. That's the best we can do and is more aligned with what a user expect from an update feature. With a good documentation that would be perfect. You can reuse the method created when working on metadata (don't remember the name). "If update is supported, now I know what you will ask next....ability to read in just the properties files or just the relations file without the elements file." No, I'm still able to create some dummy files with just headers in them ;-) |
I've created a new "csv-import" branch, tidied and consolidated. It supports updated element/relation names and documentation on import. Property values are updated if the property key exists. If more than one property exists with the same key then only the first one is updated. |
I did some tests yesterday and faced on big issue: I got an error message about one relation and then import failed. To reproduce, just open Archisurance, export it and then try to import it in a new, empty, model. |
Yes, so did I. That's why I removed the illegal relationship from the Archisurance example in 2c71cad The importer checks for illegal 2.1 relationships and reports them. Otherwise there's a danger that people will create illegal Archimate CSV files. |
In fact I did it the way around : I first tested with one of my (hand edited) model, so I thought the issue was linked to so manual edits. I then check with Archisurance and though it was fully archimate 2.1 compliant. I will retry (and play with it) tonight |
I've just (re)tested: it works great ! |
Clsoing. Archi 3.0. ;-) |
See https://groups.google.com/forum/#!topic/archi-users/Dujr_gUhFY8
This means that we need 3 files per export/import:
*Documentation (newline have to be managed in a way or another)
Remarks:
Export should either create 3 files in a folder or a zip containing them. Import should either ask explicitly for each file or take a folder and assume filenames to be (eg.) elements.csv, relations.csv, properties.csv
Of course, my assumption is that we export/import only model, not views... So this leads me to the following requirement: we should have to option to import on an already existing model so that elements that exist are updated and new ones added. Deletion could also be manage (but enable only through an option): element which exist in model but not in import file are deleted.
(Jean-Baptiste Sarrodie)
The text was updated successfully, but these errors were encountered: