问题描述
我想将数据追加到现在在Robot Framework中不为空的.csv文件中,但是遇到一些问题.
I would like to append data to .csv file which is not empty in Robot Framework now, but I meet some questions.
我从github的'robotframework-CSVLibrary'的's4int'安装了CSVLibrary,它的关键字为'Append To Csv File'.我可以将数据追加到.csv文件中,但是格式存在一些问题.
I installed CSVLibrary from 's4int' of 'robotframework-CSVLibrary' in github and it has a keyword named 'Append To Csv File'. I can append data into .csv file but there are some issues with the format.
首先,我有一个空的csv文件,并在Robot Framework中运行脚本.
First I have an empty csv file and I run my scripts in Robot Framework.
*** Settings ***
Library Selenium2Library
Library CSVLibrary
*** Variables ***
*** Test Cases ***
test
${list}= Create List apple pear
Append To Csv File ${file_path} ${list}
文件看起来像这样:
但是我希望是:
!
如何附加数据以显示预期的效果?我的格式不对吗?还是有其他方法可以实现它?非常感谢.
How can I append data to show like what I expect? Is my format wrong? Or is there any other way to realize it?Thanks a lot.
推荐答案
看来,对于正在使用的库,Append to csv file
需要一个列表列表.每个列表代表一行,每个子列表代表该行中的列.
It appears that with the library you are using, Append to csv file
requires a list of lists. Each list represents a row, and each sublist represents the columns in the row.
由于您希望"apple"和"pear"位于同一行,因此需要将它们放在一个列表中,然后将该列表放在另一个列表中.
Since you want "apple" and "pear" to be on the same row, you need to put those in a list, and then put that list in another list.
*** Test Cases ***
test
${list}= Create List apple pear
${data}= create list ${list}
Append To Csv File ${file_path} ${data}
这篇关于如何在Robot Framework中将数据附加到csv文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!