問題描述
我想將數據附加到現在在 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 文件?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!