intellij-csv-validator icon indicating copy to clipboard operation
intellij-csv-validator copied to clipboard

Header tooltip shows wrong values when csv has multiple header blocks

Open ptahchiev opened this issue 7 years ago • 5 comments

Hello, I tested the latest SNAPSHOT regarding #23 and the tooltip shows wrong values if there's more than one header in the file wrong-header

Further more if there's a typo in a word, or for some reason IDEA thinks there's a typo in the word it shows "There's a typo in the word 'XXX'" and hides the header tooltip.

Also when I position the cursor on empty value I don't get any tooltip - this actually defeats the main purpose of the tooltip, i.e. to give you a hint what value you are supposed to write.

Last but not least when selecting a value seems like all the columns and headers are marked as purple - regardless of the fact that they belong to separate blocks with separate headers (see screenshot).

All in all I think these issues can be addressed if the users were able to specify a list of block delimiters (like empty line, or the word COMMIT, or END).

Thank you for your hard work - I think this plugin is getting very nice :))

ptahchiev avatar Jun 25 '18 08:06 ptahchiev

Hi @ptahchiev,

thank you for your constant feedback - it really helps to improve and develop the plugin!

I tested the latest SNAPSHOT regarding #23 and the tooltip shows wrong values if there's more than one header in the file

This plugin follows the CSV definition of RFC4180. "Header" is only defined (optional) as the first line in CSV - more than one header is not possible from a language point of view. I understand that the CSV format is flexible and can be interpreted/used for very custom scenarios that are independent of the original language definition.

The purpose of the plugin is to support the very generic use and edit of CSV files, it can not (and is not meant to) fulfill the requirement of custom interpretation of the format. Please bear with me that I cannot support custom/individual use cases and requirements.

Said this, I am interested to get more insights in your use case and maybe find a solution that covers a very generic use-case of CSV, that benefits the majority of users as well. Lets use this thread to iterate about the multi-header requirement.

PS: I opened a separate issue for the tooltip on empty fields - see #39.

SeeSharpSoft avatar Jun 25 '18 09:06 SeeSharpSoft

Hi @SeeSharpSoft thank you for your feedback. My usecase is the following: I have CSV files which follow this syntax:

  • there are multiple blocks with data in one csv file.
  • each block has one line of header
  • the header begins with JPA command (such as INSERT, MERGE, REMOVE) followed by attributes of the JPA entity you want to update.
  • each attribute has certain input processors defined in square brackets which define how the value will be processed before being assigned to the JPA entity.
  • each block is separated by each other with an empty line or the word COMMIT

So the final result looks something like this:

MERGE com.nemesis.platform.core.entity.user.UserGroupEntity, code[id]            , description                                                 , loginDisabled[bool]  , superGroups[split=|;attr=code]
                                                           , csmanagergroup      , User group for Customer service agents                      , FALSE                , employeegroup
                                                           , premiumcustomergroup, User group for premium customer                             , FALSE                , customergroup
                                                           , basiccustomergroup  , User group for basic customers                              , FALSE                , customergroup
                                                           , businessgroup       , User group for principals that can create their own business, FALSE                ,

MERGE com.nemesis.platform.core.entity.user.EmployeeEntity , code[id]            , firstName                                                   , lastName             , displayName                        , encodedPassword[passwd]                            , userGroups[split=|;attr=code]
                                                           , csmanager           , CS Manager                                                  ,                      , CS Manager                         , 1234                                               , csmanagergroup

MERGE com.nemesis.platform.core.entity.user.AddressEntity  , code[id]            , billingAddress[bool]                                        , shippingAddress[bool], line1                              , line2                                              , phone                        , postalcode, town , country[attr=code]
                                                           , sofia-mall-address  , false                                                       , false                , "boulevard Tsarigradsko shose 123a",                                                    , "+359 885 740 222"           , 1000      , Sofia, bg

I already have my own plugin that adds a button to import the CSV into the database with a single-click: https://github.com/nemesis-software/nemesis-intellijidea-plugin

so if you provide me with some hooks so I can extend your plugin in my plugin and override the behavior that would be great. I am new to writing IntellijIDEA plugins so your guidance will be much appreicated :)

ptahchiev avatar Jun 25 '18 10:06 ptahchiev

Hi @ptahchiev,

thanks for sharing, I got your use case - which is btw quite similar to an importing concept of my team ;)... with one key difference: We do not combine different types of entities in one CSV file.

I am quite hesitant about this approach. It somewhat contradicts my idea of a CSV, namely: Having a bunch of homogeneous data bundled in an easy machine readable and human managable presentation.

So, here is what I imagine for your complete roundtrip: image (This is just an amateurish edited screenshot to provide some visual support)

It's basically splitting the data into single CSV files and having your import plugin not working on the editor window but on the Project view: It combines the content of all selected files (I think the order of the file selection can be taken into account here) to send it to the backend. This keeps your import procedure intact and is compliant with the "standard" CSV format... Do you think this would be feasible for you?

SeeSharpSoft avatar Jun 27 '18 19:06 SeeSharpSoft

Hi @SeeSharpSoft

I get your point but i don't think it will work in my case. Right now I have about 100 csv files. If I split each block into a separate csv I think i'll have more than 2000 csv files and it would be very hard to manage. Importing is not a problem for me - I already have a way to import my csv files. Plus the plugin that I wrote already allows you to import only certain lines (just select the lines you want and click import). My struggle is with the highlighting and other features. That's why I said maybe there's a way I can extend your plugin in my plugin. Sorry, I might sound lame, but I'm really not that familiar with plugin development in IDEA.

ptahchiev avatar Jun 29 '18 17:06 ptahchiev

Hi @ptahchiev,

yes, 2000 files (or mostly entities in your case) are hard to maintain in general. Still I am a bit puzzled how putting different entities with different schemas/columns into one file does help in managing the data in the long run.

I was thinking about, how language extending features can be implemented in some kind of hook, event, callback, etc. In general, there are alot of possibilities to extend the IDE provided by IntelliJ and also to provide new and extended features to already existing plugins.

However, changing the grammar of a language - which is what you need to do - is a very fundamental intervention and I am not aware of a proper way to do so. I would actually understand if this is not supported at all by the SDK. I will keep digging and thinking about this use-case.

SeeSharpSoft avatar Jul 01 '18 20:07 SeeSharpSoft