我想将数据附加到现在在 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 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!