file-uploadloadrunnervugen

Upload csv files with comma inside it


As per my requirement, I need to upload a .csv file into the application. I am trying to simulate this using loadrunner. The issue I am encoutering is that my csv file is in the below format

Header - AA,BB,CC

Data-xyz,"yyx,zzy",xxz

On using the below statement to upload the file, I am getting an error ""line 2 contains 4 columns instead of 3"

web_submit_data("upload",
"Action=xxx/upload",
"Method=POST",
"EncType=multipart/form-data",
"RecContentType=text/html",
"Referer=xxx",
"Snapshot=t86.inf",
"Mode=HTML",
ITEMDATA,
"Name=utf8", "Value=✓", ENDITEM,
"Name=token", "Value={token_1}", ENDITEM,
"Name=upload_file", "Value={NewParam_5}", "File=yes",   "ContentType=text/csv", ENDITEM,
"Name=Button1", "Value=Upload", ENDITEM,
LAST);

AS per information provided in How to deal with a string with comma in it from a csv, when we have to read the data by using loadrunner? , I tried updating the .prm file to a new delimiter pipe, | but still i get the error.

[parameter:NewParam_5]
Delimiter="|"
ParamName="NewParam_5"
TableLocation="C:\temp"
ColumnName="Col 1"

I also notice that even though I set the delimiter to pipe, if I rightclick on the web_submit_data() and go to Parameter properties, i see a column delimiter option there as well and it is not set to pipe and is set to comma which indicates that this setting is taking higher precedence to the setting in .prm file.

Can someone please guide me the right way to set a new delimiter so that vugen recognizes and parses the csv file as I want it to.

I am using loadrunner 12.5

Thanks for your help.


Solution

  • Do you need to upload a file or a line of comma separated variables? Right now you appear to be reading a line of CSV variables, not a file as your parameter file would contain a list of filenames or a single file reference within the directory of the virtual user (extra files, transferred with the use) or created by the virtual user and then uploaded.