Python 3.x 如何按顺序从CSV文件中获取数据?
我需要从CSV文件中获取数据,顺序为:R1,C1;R1,C2到R1,C10,然后R2,C1;R2,C2。。。使用机器人框架 我尝试的robotframework脚本如下所示:Python 3.x 如何按顺序从CSV文件中获取数据?,python-3.x,csv,robotframework,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} \
${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文件数据如附件所示:
当前脚本正在将数据提取为3个字符串:
名称1AGE1GENDER1
名称2age2gender2
姓名3性别3
但是我需要在变量中有Name1,然后在变量${Value}中有Age1,然后在变量${Value}中有Gender1,并逐个使用它们。
类似地,一旦完成了对第1行的操作,则应继续执行第2行,然后执行第3行。
您能解释一下您遇到的困难吗?您尝试过什么?观察到的结果是什么?请检查上述描述。我提供了一个示例和一个屏幕截图。
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.