Highlighted
Contributor.
Contributor.
1327 views

CSV File Upload fails in Vugen

Jump to solution

Hi

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);

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.

Thanks for your help.

0 Likes
1 Solution

Accepted Solutions
Highlighted
Trusted Contributor.
Trusted Contributor.

Re: CSV File Upload fails in Vugen

Jump to solution

Hey, just found out the reason for your problem.

If you were uploading a .csv file as the code below shows, LR works just fine.

    web.submitData(
        {
            name : 'cgi_return.exe', 
            action : 'http://lazarus/cgi-bin/cgi_return.exe', 
            method : 'POST', 
            encType : 'multipart/form-data', 
            targetFrame : '', 
            recContentType : 'text/html', 
            referer : 'http://lazarus/html/forms/file.html', 
            snapshot : 't2.inf', 
            mode : 'HTML', 
            itemData :  [
                {name : 'entry', value : 'aaa'},
                {name : 'name_of_files', value : 'C:\\test.csv', file : 'Yes'}
            ]
        }
    );

If I guessed right, you were trying to modity the param.dat file, however the grammer is different from .csv file. 

For instance, the data in .csv file

Header - AA,BB,CC

Data-xyz,"yyx,zzy",xxz

looks different in param.dat

Header - AA,BB,CC

Data-xyz,yyx\,zzy,xxz

 

For your problem, I sugeest you save the data in a csv file and set the value as the path for the csv file, or modify the data in the format in existed param.dat files. 

 

BR

Lynn

View solution in original post

2 Replies
Highlighted
Trusted Contributor.
Trusted Contributor.

Re: CSV File Upload fails in Vugen

Jump to solution

Hi arach,

Is this error message dispalyed within Vugen?

And I am not sure the .prm file is related.

0 Likes
Highlighted
Trusted Contributor.
Trusted Contributor.

Re: CSV File Upload fails in Vugen

Jump to solution

Hey, just found out the reason for your problem.

If you were uploading a .csv file as the code below shows, LR works just fine.

    web.submitData(
        {
            name : 'cgi_return.exe', 
            action : 'http://lazarus/cgi-bin/cgi_return.exe', 
            method : 'POST', 
            encType : 'multipart/form-data', 
            targetFrame : '', 
            recContentType : 'text/html', 
            referer : 'http://lazarus/html/forms/file.html', 
            snapshot : 't2.inf', 
            mode : 'HTML', 
            itemData :  [
                {name : 'entry', value : 'aaa'},
                {name : 'name_of_files', value : 'C:\\test.csv', file : 'Yes'}
            ]
        }
    );

If I guessed right, you were trying to modity the param.dat file, however the grammer is different from .csv file. 

For instance, the data in .csv file

Header - AA,BB,CC

Data-xyz,"yyx,zzy",xxz

looks different in param.dat

Header - AA,BB,CC

Data-xyz,yyx\,zzy,xxz

 

For your problem, I sugeest you save the data in a csv file and set the value as the path for the csv file, or modify the data in the format in existed param.dat files. 

 

BR

Lynn

View solution in original post

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.