Hi dtdave,

On 16/10/2019 12.28, 'dtdave' via Django users wrote:

In my script for importing from a csv I seem to run into the following error:
could not convert string to float
The relevant part of the script is as follows:
area_hectares=float(row[6])


That is impossible to tell without seeing the contents of your CSV file, but obviously row 6 of that file at least sometimes contains something that cannot be converted to a float.

I'd suggest you simply print out the values of row 6 in your script to see which values you cannot convert and then handle that. Possibly it's an empty string, in which case you might want to handle that by converting that to a NoneType, but that depends on your use case of course.

Kind regards,

Kasper Laudrup

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6360fe4d-e3f2-6825-e73a-ca93084667ae%40stacktrace.dk.

Reply via email to