如何以顺序方式从CSV文件中获取数据?

时间:2019-06-14 12:13:48

标签: python-3.x csv robotframework

我需要按照以下顺序从CSV文件中提取数据:R1,C1; R1,C2直到R1,C10然后是R2,C1; R2,C2 ...使用机器人框架。

我尝试过的robotframework脚本如下:

 ${File}=    Get File              Text Files\\Book1.csv
    @{list}=    Split to lines  ${File}     
        :FOR    ${line}    IN     @{list}    
         \    Log                             ${line}
         \    ${Value}=   Get Variable Value  ${line}
         \    Input Text    LOCATOR      ${Value}
         \    Press Keys    LOCATOR       RETURN  

预期:脚本应按以下顺序提取数据:R1-C1,C2,C3 .... C10;                                                     R2-C1,C2,C3 ...... C10直到最后一行。

实际:脚本正在单次尝试从R1- C1,C2,C3获取数据。 CSV文件数据根据附件CSV File

The current script is fetching data as 3 strings : 
Name1Age1Gender1
Name2Age2Gender2
Name3Age3Gender3

But I need to have Name1 in variable <${Value}>, then Age1 in variable ${Value}, then Gender1 in variable ${Value} and use them one-by-one.

Similarly, once it is done with Row1, then it should proceed to Row2 and then Row3.

0 个答案:

没有答案