I want ro read and save data from CSV to list and sent to server. My Algorithm: 1. Open CSV file 2. Check data in CSV file, if in CSV file no data I don't want to save to list but if in CSv have data, the Data will save to list and sent to server. 3. Delete data after read
I've got problem in step 2 and 3 for no data my sistem sent blank list to server. I use python 2.7 and there is my code: `def readFile(self): try: print "open " + self.filename f = open(self.filename) csv_f= csv.reader (f)
except IOError:
print 'cannot open file'
else:
## Read the first line
print "file opened " + self.filename
## If the file is not empty keep reading line one at a time
## till the file is empty
for row in csv_f:
Data.append(row)
del (row)
f.close()
return Data
Can you help me?