I'm trying this code to import data from csv into database and works fine.
I don't need to populate a table with the data, so I'm trying to avoid this step, but there is an error I can't solve. This is the code:
#1. Read data
csvData = csv.reader(open(system.file.openFile('csv')))
#2. Populate table with data
event.source.parent.getComponent('Table').data = system.dataset.toDataSet(csvData.next(), list(csvData))
# Create a dataset with the header and the rest of our CSV.
dataset1 = event.source.parent.getComponent('Table').data
dataset2 = system.dataset.toDataSet(csvData.next() ,list(csvData))
dataset1 and dataset2 should be the same, as I assign in point 2 the data from csv.
but creating dataset2 shows this error:
Caused by: org.python.core.PyException: StopIteration
Do you know why two datasets are not equal? I think I'm missing something.
thanks!