.csv excel file reading Error in sikuli

Asked by Dinesh Pawar

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:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:

This question was originally filed as bug #1687890.

Revision history for this message
RaiMan (raimund-hocke) said :
#1

a newbee error not having enough Python knowledge.

Revision history for this message
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

Revision history for this message
Dinesh Pawar (dineshpawar22) said :
#3

Thanks RaiMan, that solved my question.