0

I'm a complete noob at this as I have not done any coding for a while. trying to make my life a little easier by automating a job I'm doing. I've created a script to input "first name" "last name" but it seems to just pulls the last field from my csv . can anyone help!!!

import csv

input = open('C:\Sikuli\jslogic.csv', 'rb')

for row in csv.reader(input):
firstColumnValue = row[0]
secondColumnValue = row[1]


click("1477300865566.png")
wait("1477300892860.png")

click(Pattern("1477300892860.png").targetOffset(-60,-83))
wait(Pattern("1477300993973.png").targetOffset(-6,43))
click(Pattern("1477301019405.png").targetOffset(-107,14))
paste(firstColumnValue)
type(".")
paste(secondColumnValue)
click(Pattern("1477302537861.png").targetOffset(89,27))


click(Pattern("1477302228123.png").similar(0.88).targetOffset(108,54))

click(Pattern("1477301587806.png").targetOffset(-1,-2))

The CSV is just a basic one made in excel just a table denoting first name and last name as follows

First Name  Last Name
testy   Mctestface
testy1  Mctestface
testy2  Mctestface
testy3  Mctestface
testy4  Mctestface

It Currently pulls from the CSV entering but only uses the last value in the table so in the current table Testy4 mctestface

Shubham Jain
  • 16,610
  • 15
  • 78
  • 125
Phillious
  • 1
  • 1
  • Could you give a few rows worth of data from your csv file so we can see what you are actually trying to parse, what's the expected outcome and what you are currently getting? – Christian W. Dec 05 '16 at 12:04
  • sorry it also needs to loop and go onto the next row for the next entry. – Phillious Dec 05 '16 at 12:05
  • First Name Last Name testy Mctestface testy Mctestface testy Mctestface testy Mctestface testy Mctestface – Phillious Dec 05 '16 at 12:06
  • So your separator in the csv file is space? Have you tried using `delimiter=' '` in your reader? – Christian W. Dec 05 '16 at 12:09
  • There should be no spaces in it unless it put one in when it reads it . i tried it but possible used it wrong . it has been a good 5 years since i last tried my hand at coding and it is very much showing – Phillious Dec 05 '16 at 12:14
  • Your Python code is not formatted correctly so it's impossible to know what is included under your `for` loop. Please format your example code properly. – Eugene S Dec 05 '16 at 15:35

1 Answers1

0

In Python, if you read a file line by line, it remembers the last line and does not go back automatically. If you read this file somewhere prior to that part of your code that you posted, that might be the issue.

A quick test can be adding the following line before you start iterating over the file content, so:

f.seek(0)
for row in csv.reader(input):
. . . 
Eugene S
  • 6,709
  • 8
  • 57
  • 91