.csv excel file reading Error in sikuli

Asked by Dinesh Pawar on 2017-05-03

Hi friend I am new for Sikuli
I want to read excel file so, i save Excel File in .csv format(CSV Comma delimited)
and

my code is

import csv
out = open('C:/Users/e592134/Desktop/New folder/example1.csv' , 'rb')
data = csv.reader(out)
    data=[row[1] for row in data]
print(data[0])
print(data[1])
print(data[2])

and I got ERROR as bellow

[error] stopped
[error] an error occurs at line 4
[error] error message;
syntax Error: <"mismatched input '' expecting EOF"", <'C:\\Users\\h224834\\Appdata\\Local\\Temp\\sikuli-tmp158639032712181619.py',4, 4, ' data=[row[1]] for row in data]\n'>>

please help.

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
2017-05-04
Last query:
2017-05-04
Last reply:
2017-05-04

This question was originally filed as bug #1687890.

RaiMan (raimund-hocke) said : #1

a newbee error not having enough Python knowledge.

Best RaiMan (raimund-hocke) said : #2

the docs should have helped:
https://docs.python.org/2/library/csv.html

import csv
out = open('C:/Users/e592134/Desktop/New folder/example1.csv' , 'rb')
data = csv.reader(out)
for line in data:
    print(data[0])
    print(data[1])
    print(data[2])

BTW: your original code has an indent problem

   data=[row[1] for row in data]
should not have whitespace in front, since it is level 0 code

Dinesh Pawar (dineshpawar22) said : #3

Thanks RaiMan, that solved my question.