Nov-03-2017, 01:11 AM
(Nov-02-2017, 04:00 PM)DeaD_EyE Wrote: The order of steps in your program:
- Read a line
- Convert data of the line
- Make decision if data is in boundaries
- If data is in boundaries -> yield data
At the end it's very easy. Make a function which decides if your data is in your boundaries and do something with it.
No need to make this strange nested iteration.
What you need to know:
- Exception handling
- argument unpacking
- keyword argument unpacking, if you're working with dicts. Not necessary.
- functions
- use of csv module
- knowledge of iterables, csv.reader is an iterator
- comparison with more than one value (min_val < val < max_val)
- logical operations: and, or, not
DeaD_EyE, i really love your coding style and the simplicity and comment you used to let me understand everythings.
I losted 1 hour trying to make the nested itineration working while you did it in a simpler and nicer way. I think i am still using a C style way and in python i shouldn't use the same approach i am used to
i really liked how did you manage the errors, as an hobbyist i am not used to this but i know that good programmers and code manage all the possibilities
the map function is very powerful, i didn't know about it (well in C it is something very different ) i will use it in the future for sure
the only thing i didn't understand well, even if i read the doc, was the partial(), i found it so confusing that i decided to remove it and made it more readeable for myself:
lat_min= 37.547550 lat_max= 37.547570 lon_min= 15.143184 lon_max= 15.143196 def in_boundaries(lat, lon): return lat_min < lat < lat_max and lon_min < lon < lon_maxi know this is not good as your but it works the same and for me is sympler
using your code i just had to append() the good value in a new list and i have my new database ready to be written in a new csv file
again I say you a big thank you