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
Import data into custom fields from CSV (& other file formats) #4270
Comments
You need to write a fairly complex code. |
:-) well, ok. More details please. Which step is the most complex one?
Since I'd like to import my data as losslessly as possible and need to get it out of a completely different SQLite schema (iFinance app), I'll probably implement a custom data import in Ruby (with SQLite3 library). Let's see where this will get me. Split transactions are also going to be exciting. |
I'm working on this for 1.6.5, estimate about 80% finished. Basic idea is pretty straightforward, all custom fields will appear in the the import dialog after the default list. They are shown using their field descriptions: In the DB they are saved/restored using their FIELDIDs so that renaming the custom field doesn't affect saved presets. Identified by the prefix Currently I'm working on data validations, and I have a few questions that should be discussed. One basic question is "If the value a user is attempting to import into a custom field fails data validation (perhaps they attempt to load a decimal into a custom date field, or they load a value into a "choice" field that isn't one of the choices), should the record be rejected (with some suitable error message) or should the record be loaded but the failed custom fields initialized to the default values?" Lets look at validations type-by-type. Here is what I currently have implemented and a few questions which need to be considered. Looking for feedback: anything incorrect, anything missed, questions, etc.
|
This looks very good, thank you!
Generally:
Looking at it this way, it would probably be best to skip columns which have unimportable values, and also skip values which already exist, if MMEX doesn't already do this. This way, you can import a CSV, notice that some columns were skipped, correct the values with an editor, and then reimport and MMEX will fill in the missing columns. Duplicate detection could be based on date + amount + sender/payee, or some other combination of mandatory fields. |
There is no duplicate checking in MMEX right now. We can't skip columns then go back and load data to those columns on existing transactions in the DB. Its all or nothing by row.
The only mandatory fields are
MMEX already presents the user with an option to either accept the load or reject it. If the user clicks "Cancel" the load is discarded and no data is saved. I have made the log describe the errors like this:
|
And that is exactly how it should stay. The onus is on the user to correct any errors that MMEX reports in their source data file and then re-run the import. It's much safer that way and sidesteps a lot of complexity. |
Is it therefore the case that if a user chooses, perhaps unwisely, to create a custom field with the same name as a standard field ('Payee' for example), the import will still work correctly? There'll just be 2 fields named Payee in the list? |
All good.
My gut feeling is that the user should format their data appropriately before importing it. Importing a floating point value into an integer field loses precision and is probably an error. On that basis, anything that is not an integer, should be rejected. Someone might put forward the counter argument that an Integer custom field on the Edit Transaction dialog does permit the entry of a floating point value, for example, 12.49 (rounded to 12) and 12.5 (rounded to 13). However, I would say this is just a side effect of the fact that the field permits the entry of arithmetic expressions, e.g 5 + 7 + 0.3 = 12.3 (rounded to 12). There is no reason to support any of this for import. Finally, I'd say, that if the user really wants floating point values in the CSV file to be rounded to the nearest integer value when imported, then they should specify a Decimal custom field with the Decimal Places attribute set to 0.
You should follow the rounding behaviour of the Decimal custom field on the Edit Transaction dialog.
Again, I think the user should be responsible for formatting their data appropriately. However, I would have no reason to object if you chose to implement @jensb's suggestions of "t", "1", "Y", "true" = True, "f", "0", "N", "false" and "" = False (all case insensitive) provided that there was no expectation that the user would get anything other than "True" or "False" back if they subsequently exported the data from MMEX. BTW, I don't think that the list of aliases for True/False should be configurable (as @jensb suggests). I think this is OTT unless people can present real-world use cases for such a feature where it would be unreasonable for them to have to pre-format the data in their CSV file.
I think that unless people can present real-world use cases where it would be unreasonable for them to have to pre-format the data in their CSV file, requiring the custom date field to have the same format as the selected Date format is sufficient. It keeps the Import and Export UI simple.
Do you require the full hh:mm:ss (i.e. the same format as displayed in a Time field) or are hh, hh:mm, or hh:mm:ss all accepted?
All good.
It's an error in the data. Reject the record (and therefore the Import) so that the user can fix their data. |
Precisely. Users can name them whatever they want. All backend processes use IDs rather than text descriptions to handle the data to avoid any conflicts.
Will leave the logic as implemented then.
I can use the same format specifier "%.*f" so behavior is identical.
I have added these additional values. They are not user configurable.
The wxDateTime::ParseTime function is pretty lenient. It will take hh, hh:mm (with optional am/pm), or hh:mm:ss. |
If a custom field is selected for import and the custom field has a default value configured, should we populate the default value if a value is not provided by the file, or would users expect the field to stay empty? I suppose the default value is more for convenience of entering new transactions within MMEX. It is not intended to automatically provide a value for every transaction, the user still has to click the check box to associate the default value with the transaction. Therefore I am inclined to leave them blank if they are imported with no value. |
This is pretty much done, so once 1.6.4 is released I'll open a PR so others can test it out. |
Import & export of custom field data for both CSV and XML formats is now available for testing. |
feat(#4270): custom field import & export for CSV/XML
@jensb Are you satisfied with the functionality? Can we close this issue? |
I'd have to check some details with my data, but from what I've read, this is even more than I was hoping for. Thanks! |
It is possible to create custom fields for transactions which is a very valuable feature.
I would like to import transaction data from another finance app (almost 18 years of it to be honest) and these transactions contain columns not just for date, value, payee, notes and category, but also for
I created custom fields for these values, but I can't import them from the CSV because the custom fields cannot be selected/assigned to columns in the import dialog.
What would need to be done to allow users to import data into the custom fields?
The text was updated successfully, but these errors were encountered: