1

csv当我使用 Loadrunner 时,它可以从文件中读取数据。众所周知,csv文件以逗号分隔。

问题是,如果参数 incsv本身有逗号,字符串将被分成几个段。那不是我想得到的。

我们怎样才能得到带有逗号的原始数据呢?

4

4 回答 4

1

当数据有逗号时,使用转义字符将数据存储在参数中。例如,如果名称为“Smith, John”,则可以在 Loadrunner 数据文件中将其存储为 Smith\, John。

于 2017-03-22T17:02:19.617 回答
0

当您在 Excel 中保存在实际单元格数据中包含逗号的文件时,整个单元格将位于两个 " 字符内。此外,其中带有空格的单元格似乎在 " 字符内。

例子

ColA,ColB,"ColC with a , inside",ColD,ColE

有关 CSV 文件格式的更多信息:http: //www.parse-o-matic.com/parse/pskb/CSV-File-Format.htm

问题的答案是,处理 , 分隔符的最简单方法是将分隔符更改为; 特点。这也是 CSV 文件中的有效分隔符。

那么示例将是:

ColA;ColB;"ColC with a , inside";ColD;ColE
于 2012-10-09T11:11:27.903 回答
0

Maybe the right way is to use C functions to read data from the file (for example fopen/fread)? When you have read it you be able to use "strchr" to find first quotes char and second quotes char. All in that interval would be a value, and it doesn't matter if comma is inside. For the documentation about fopen, fread,strchr, you could refer to the HP or C function references. Hope this will help you.

于 2012-10-09T11:16:50.357 回答
0

Assuming you are reading from a data file for the parameters, just use a custom seperator. Comma is the default, but you can define it to be whatever you want. Whenever I have a comma in the variable data I tend to use a pipe symbol, '|' as a way to distinguish the columns of data in the data file.

Examine your parameter dialog carefully and you will see where to make the change.

于 2012-10-09T13:01:48.643 回答