nasa / CCDD

CFS Command and Data Dictionary Tool (CCDDT)
81 stars 31 forks source link

CSV File Import Failure #102

Closed jodi-j closed 1 year ago

jodi-j commented 1 year ago

When trying to import CSV files through the command line and GUI, the files fail to fully import. The CSV files have been created by C_struct_to_CSV_conversion, and the issues seem to stem around structs that have arrays as parameters.

Command Line

Structs in the CSV file will import properly up until the first struct to contain an array. Once a struct with an array is reached, a table will be created for it but no data will be imported. Any structs in the file listed afterwards will not be imported at all.

The following examples are errors that have appeared when attempting to import a CSV file through the command line:

CCDD : Invalid Input : Invalid characters in table 'CS_TableNameCmd_t' for column 'Array Size'; characters consistent with input type 'Array index' expected

CCDD : Invalid Input : Index: 13, Size: 13

The command used: $ java -jar CCDD_beta.jar -project myproject -host localhost -user myuser -password mypassword -import 'importFileType CSV -filename myfile' -shutdown

GUI

When attempting to import through the GUI, a table is created for each struct. However, with structs containing arrays, all parameters will be imported up to the array itself and any parameters afterwards fail to import. Structs without arrays are imported normally.

Example data for an import:

image

Actual import:

image
KevinMcCluney commented 1 year ago

First, thanks for the details - I was able to recreate the issue, which makes troubleshooting go more quickly!

Short version: Array members are expected in the import file. You CSV file has the array definition for spare1, but not the 8 array members. If you include the 8 member rows the CSV file imports successfully. Skip to Potential Change below in you don't want to know why CCDD acts the way it does.

Long version: Importing table data (in any format) utilizes the same code as when pasting data in from the clipboard. Prior to version 2.1.1 code was in place that attempted to handle every possible combination of pasted array variable data - array definition only, array member(s) only, array definition and members, missing array members, etc. The code could only accommodate arrays of up to 3 dimensions. Not only was it slow, but it didn't work in many cases, was difficult to debug, and was prone to break when other updates were made.

Starting with version 2.1.1 the paste operation was simplified. It behaves as if the user is typing in the cells, in order, one at a time. There is no special accommodation for arrays except that a data table that can have arrays (i.e., a structure) has the arrays expanded prior to pasting the data. This is what caused the error you experienced.

Your CSV file has an array definition (for spare1), but no array members. When this is imported the table, being a structure, has array expanded. When the array spare1 is created, 8 rows are automatically inserted below it for the members. The next row of data in the CSV file (for IngestPackets) is pasted into the row for spare[0], resulting in the error condition as mismatches occur.

Potential Change: I've come up with a modification that would work for the case you have: if one or more array definitions is in the imported (pasted) data, but no array members, the arrays will not be expanded. For your CSV file this allows IngestPackets to skip the 8 spare1 array member rows. Note that there is no allowance for some arrays having the members in the file and some not - it's all or nothing. I'm testing the added code and, assuming no issues arise, it will be part of the next version, 2.1.4.

KevinMcCluney commented 1 year ago

Version 2.1.4 incorporates the 'potential change' described above.