JMeter data source CSV Data Set Config from command line - csv

I have a JMeter setup which reads data from a CSV file configured in CSV Data Set Config element. It works fine, the CSV file is specified in CSV Data Set Config -> Filename.
Now I want to envoke JMeter from command line instead of GUI, and I want to specify a different filename for the above element. How to go about it?
I tried "-JCSVNAME=" but it does not seem to work.
Ideas?

Just use __P function in the Filename field of Listener
Then on command line , add this:
-Jdatadir=full path to folder that contains CSV

Just change the Filename field in CSV Data Set Config to ${__P(datadir)}.
Include the following option while using jmeter.
-Jdatadir=path_to_the_config_csv
Example:
jmeter -Jdatadir=/home/InputData.csv -n -t /home/request.jmx -l some.csv
CSV Data Set Config

Related

Dynamic server name using variable in Jmeter

I am using a csv file to load the data into jmeter.
Also, a part of the sever name is stored in the same csv file.
I need to create the sever name something like this:
${usernameInCSV}.twitter.com
The above syntax is not working for me. In solutions to achieve this?
You syntax looks correct.
Check the CSV DataSet configuration (can you show yours?):
You have set variables (one of them is usernameInCSV) are separated by comma in the element configuration
you have set separator and it matches the one in csv file

How to convert dbase III files to mysql?

is ist possible to convert .DBF files to any other format?
Does anybody knows a script, that can be used to convert .DBF files to an mysql query.
It would be also fine, to convert the DBF files to CSV files.
I always got problems with the codec of the DBF files.
Konstantin
https://www.dbase.com/Knowledgebase/faq/import_export_data.asp
Q: How do I export data from a dBASE table to a text file?
A: Exporting data from dBASE to a text file is handled through the COPY TO command.
Like the APPEND FROM command, there are a number of ways to use this command. Here we are only interested in it's most basic use. Once you understand how to use this command, you can go to your on-line help for further details on what can be accomplished with the COPY TO command.
In order to export data you must first be using the table from which the data will be exported. As before, you will be employing the USE command in the command window.
USE <tablename>
For example:
USE Mytest.dbf
Once the table is in use, all you need to do is type the following command in the command window:
COPY TO <filename> TYPE DELIMITED
For example:
COPY TO Myexport.txt TYPE DELIMITED
This would result in a file being created in the current directory called Myexport.txt which would be in the DELIMITED or *.CSV format.
If we had wanted to export the data in the *.SDF format, we would have typed:
COPY TO Myexport.txt TYPE SDF
This would result in a file being created in the current directory called Myexport.txt which would be in the System Delimted or *.SDF format.
Those are the basics on how to import and export text data into a dBASE table. For further information consult the on-line help for the APPEND FROM and COPY TO commands.
I converted old (circa 1997) DBF files to CSV using Python and the dbfread module.
After installation of Python, from the Python interpreter (<WIN> + 'Python') install the dbfread module:
>>> pip install dbfread
The module has many method to read DBF files and excellent documentation.
Then a Python script does the job, or typing directly into the interpreter:
# Read the DBF file
table = DBF('C:/my_dbf_file.dbf', encoding='1252')
outFileName = 'C:/my_export.csv'
with open(outFileName, 'w', newline='', encoding='1252' ) as file:
writer = csv.writer(file)
writer.writerow(table.field_names)
for record in table:
writer.writerow(list(record.values()))
Note that each record in the database is read and save one at a time and that the first line of the CSV file are the column's names.
Encoding could be problematic, a list of encoding to try is here: The dbread.DBF() method tries to guess the encoding but is not perfect. This is why in the code I specify the parameters encoding in both DBF() and csv.open().

Importing data from a csv file in Jmeter

I tried to import data from a csv file. But it is not working. Can anybody help me?
My csv file:
username,password
usr1,pswd1
usr2,pswd2,
usr3,pswd3
......
.....
My CSV Data Set Config:
File name: D:\Jmeter\Data\Login.csv
Variable names: username,password
Allowed quoted data?:True
Recycle on EOF?:False
Stop thread on EOF?:True
But in the request body the username and password are not reflected
POST data:
__EVENTTARGET=ctl00%24ContentPlaceHolder1%24submit_btn&__EVENTARGUMENT=&__VIEWSTATE=5yDYRGJAvmOFe2yRZWqpXcU%2Fjy4d3kuQN0MiJSPN%2BSjcO4%2BWHatlhSCDH%2FYSsVkXcmaeSOeM5tgjxITgfplBaZdFcWAehSjSj6pCmpSNqI0%3D&__EVENTVALIDATION=rLAwRsfGRJxIUNuCrGNKSRwRWmH8KlXvFg85hbvt%2FUx9fI3qEEImGpMg%2Fi97mHb20kuESntswMVH5c%2BTkET8ludQxvA9%2Bnoz2wV2W4d%2FgcvK0rvRULKQhR4OxiVNJXQq2q3bR1cIUpYOIFbTEOyumwLlATsfrS1eAfuKZ8UEkeY%3D&ctl00%24ContentPlaceHolder1%24username_txt=%24%28username%29&ctl00%24ContentPlaceHolder1%24password_txt=%24%28password%29
I am just elaborating that how to creating\importing data from CSV
1.Create a CSV file in desired path-->D:\Jmeter\Data\Login.csv
Having data like this:-
usr1,pswd1
usr2,pswd2
usr3,pswd3
2.Add the csv data config similler to attached image
3.Use the username and password where you want like below snapshot
Hope it will work for you

Receiving Error While passing Dynamic Values From CSV in JMETER

Please check the below steps I followed in my test.
First, created a CSV file with the username and password. I have done this in a text editor, and saved as .CSV file.
My CSV Looks Like:
username password
user 1 pwd 1
user 2 pwd 2
And I placed in the Specific path and I have mentioned in the same path in CSV Data Set Configuration steps.
File Name : mentioned full path of the file.
Variable names : username,password
Delimiter : ,
Next I Have defined the below changes in HTTP Request
username with ${username}
password with ${password}
After running the test, the passed user logins are not taking from the script and the test got failed.
please guide me if some where am wrong.
Here's how your input file and Jmeter item should look like:
If your CSV file is actually separated by tabulation symbols you need to change the delimiter to \t
I would suggest removing leading "username" and "password" from your CSV file, JMeter won't recognise header so you'll have at least one failed request.
Other bits look good.
You may also want to check out Using CSV DATA SET CONFIG guide and __CSVRead() function.

Importing .csv files and saving as .dta

I have a folder containing a number of csv files, e.g. "leeds dz.csv", "leeds gh.csv", "leeds fr.csv". The first part of the file names is constant (i.e. always "leeds").
I want to import each to Stata individually, convert to .dta file and save it. Currently I have this code:
cd "etcetc"
clear
local myfilelist : dir . files"*.csv"
foreach file of local myfilelist {
drop _all
insheet using `file', comma
local outfile = subinstr("`file'",".csv","",.)
save "`outfile'", replace
}
The code works fine if I rename all the .csv files manually to delete the "leeds" part, ie if each .csv is named "dz.csv" instead of "leeds dz.csv" etc.
However, if I do not do this deletion I receive the error "invalid 'dz.csv' "
I'm guessing this has something to do with my 3rd line of code, in particular the "*.csv". But I'm unsure how to adapt the code/ why it won't allow me to import files with a space in the name?
The line
insheet using `file', comma
will be problematic with any filename containing spaces.
Try
insheet using "`file'", comma
The help for insheet is quite explicit on this:
If filename is specified without an extension, .raw is assumed. If your
filename contains embedded spaces, remember to enclose it in double
quotes.