zerocode icon indicating copy to clipboard operation
zerocode copied to clipboard

Parameterized csvSource with body payload from reusable external JSON file

Open authorjapps opened this issue 5 years ago • 10 comments
trafficstars

From Slack: @Dorian

Hello, is it possible to use csv data in a reused son?

Because the ${0} like variables in the file aren't getting swapped with the values from the csv.

...
"body": "${JSON.FILE:notification-api/parameterizable_body_pos_csv.json}" 
...
"parameterized": {
    "csvSource": [
      "Amelia, Loska, 1969-02-06, female, Im Grunde 082, Thörnich, 54340",
      "Pauline, Brand, 1967-01-29, female, Schöneberger Str. 71, Strande, 24229"
    ]
  }

This looks like anew feature request which needs to be implemented.

Please recheck the behavior before implementing it.

Current: Inline CSV data in the "parameterized" block work fine

Desired: CSV data from external source should work in similar fashion.

AC Details

From the perspective of the changes, the following is a better way. e.g. Currently, it works this way.

    "parameterized": {
        "csvSource":[
            "octocat,      The Octocat, San Francisco, 583231",
            "siddhagalaxy, Sidd,        UK,            33847730"
        ]
    }

What should be ideal is to source this from a CSV file e.g.

    "parameterized": {
        "csvSource":"${CSV.FILE:my_data/params.csv}"
    }

where the params.csv content will be e.g.

user,name,city,userid
octocat,The Octocat,San Francisco,583231
siddhagalaxy,Sidd,UK,33847730

The 1st line is the header which can be ignored while reading.

authorjapps avatar Jun 18 '20 19:06 authorjapps

I would like to help but am totally new to this project. Can you please elaborate more on this?

pradeeppg89 avatar Jul 07 '20 09:07 pradeeppg89

@pradeeppg89, thanks. Updated the description section. Let us know if you are able to reproduce the issue!

authorjapps avatar Jul 08 '20 11:07 authorjapps

@pradeeppg89, are you still looking into this?

authorjapps avatar Jul 16 '20 06:07 authorjapps

Hi @authorjapps I'm trying to understand the above issue and I understood that something like the below might be required.


"parameterized": {
    "csvFileSource": {
     test.json
    }
  }

Now the csvFileSource can also be a list. I'm more or less sure that the above is wrong. Could you please correct my understanding here.

Also I'm a little unclear on the reused son part. Can we please have a chat regarding this on Slack

Sauhardstark avatar Jul 17 '20 10:07 Sauhardstark

@Sauhardstark I think this is something I believe, should be reproduced as explained in the issue description. From the changes perspective, the following is better way. e.g. Currently, it works this way.

    "parameterized": {
        "csvSource":[
            "octocat,      The Octocat, San Francisco, 583231",
            "siddhagalaxy, Sidd,        UK,            33847730"
        ]
    }

What should be ideal is to source this from a CSV file e.g.

    "parameterized": {
        "csvSource":"${CSV.FILE:my_data/params.csv}"
    }

where the params.csv content will be e.g.

user,name,city,userid
octocat,The Octocat,San Francisco,583231
siddhagalaxy,Sidd,UK,33847730

The 1st line is the header which can be ignored while reading.

authorjapps avatar Jul 17 '20 11:07 authorjapps

Hi @authorjapps Is this issue fixed? if not I would like to try solving this

ShubhamAnand2098 avatar Dec 19 '20 15:12 ShubhamAnand2098

Hello @authorjapps I have raised a PR for this, can you please let me know if the PR is as per the expectation? Also is it OK to assign this to me?

imprashant avatar Feb 08 '21 06:02 imprashant

Hello @imprashant , Apologies for the delay as we were slightly busy in our day jobs. We will take a look soon.

authorjapps avatar Feb 15 '21 11:02 authorjapps

This would be a cool feature to have, really.

arjunjhnzpost avatar Aug 31 '21 06:08 arjunjhnzpost

Similar requirement has been requested in https://github.com/authorjapps/zerocode-hello-world/issues/29 as well. Parameterization of external files will be important feature that could solve multiple challenges.

automationuser-m avatar Apr 22 '22 21:04 automationuser-m

PR merged.

This feature is available in 1.3.36 (and higher version) when release.

authorjapps avatar Jan 27 '24 11:01 authorjapps