![](/img/trans.png)
[英]Robot Framework: How to read a random row in a csv files and use the values?
[英]Robot Framework - DataDriver - Select random data from a row within a .csv
我有一個包含大約 3k 行的電子表格,我正在嘗試從(特定行)中獲取 select 數據以輸入表單數據。
目前,我的代碼正在對 CSV 中的所有行重復測試,如何從隨機行中獲取 select 數據?
謝謝!
您可以輕松地在 python 中創建自己的庫,用於讀寫 csv 文件。 這是一個適用於每個文本樣式文件的快速示例。
class costomLibrary(object):
def read_specific_line(self, filename, row):
'''
This creates a keyword named "Read Specific Line"
This keyword takes the filename of the file to read and the row
wich is to be read.
'''
fp = open(filename)
for i, line in enumerate(fp):
if i == row:
return line
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.