Getting error The amount of data miss match the amount of column in data file when running a CSV File

I am trying to run a script with following:

  1. Create data.csv file through text editor
  2. Pass IDs from data.csv to pull different accounts (Succuess)
  3. Extract 4, 5 different parameters and store in Variables (Succuess)
  4. Use appendToCSV function to write the updated values to CSV.
    ${Id},${AppName},${AppStatus},${CustodianName},${EscalationName},${Mgr5},${Mgr4},${Mgr3}

CSV Header:
Id,AppName,AppStatus,CustodianName,EscalationName,Mgr5,Mgr4,Mgr3

When writing to the file using Katalon Recorder I am getting the error below even I verified the Columns manually.

[error] The amount of data miss match the amount of column in data file

Is there any other function or what is missing ?Please help.

Thanks,
Asad

@asad.hussain

How many CSV file(s) do you have? 1 file, or 2 files?

I guess, it is likely that KatalonRecorder implicitly assumes that you will use 1 input file and another 1 output file; it does not support the case where your test overwrites a single file.

Please try to use 2 files; read data.csv, write into another file output.csv.

1 Like

@asad.hussain The issue you have isn’t an issue to do with files being used for I/O purposes, the issue you have is a data structure one.

KAR it turns out is finicky about the structure of the data it expects to find in the destination CSV file. You mentioned that it has the required CSV headers… Turns out that this is not enough. You need the first row under the header also populated (e.g. with the same number of columns), without this, it’ll throw that error.

It feels like this is a bug, but at least there is this workaround.

This is the CSV structure when your operation should work:
"Id,AppName,AppStatus,CustodianName,EscalationName,Mgr5,Mgr4,Mgr3
X,Y,Z,A,B,C,D,E
"

Whereas, just using the following throws the error you’re expecting:
"Id,AppName,AppStatus,CustodianName,EscalationName,Mgr5,Mgr4,Mgr3
"

@vu.tran Do you know if what is described here (re behaviour) is expected / intentional, or a possible bug?