Python Forum
deleting certain rows from multidimensional list
Thread Rating:
  • 2 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
deleting certain rows from multidimensional list
#4
(Nov-02-2017, 04:00 PM)DeaD_EyE Wrote: The order of steps in your program:
  1. Read a line
  2. Convert data of the line
  3. Make decision if data is in boundaries
  4. 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 Snooty
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 Shifty ) 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_max 
  
i know this is not good as your but it works the same and for me is sympler Angel

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 Smile
Reply


Messages In This Thread
RE: deleting certain rows from multidimensional list - by aster - Nov-03-2017, 01:11 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Deleting rows based on cell value in Excel azizrasul 11 2,750 Oct-19-2022, 02:38 AM
Last Post: azizrasul
  The code I have written removes the desired number of rows, but wrong rows Jdesi1983 0 1,651 Dec-08-2021, 04:42 AM
Last Post: Jdesi1983
  deleting select items from a list Skaperen 13 4,674 Oct-11-2021, 01:02 AM
Last Post: Skaperen
  Pandas DataFrame combine rows by column value, where Date Rows are NULL rhat398 0 2,148 May-04-2021, 10:51 PM
Last Post: rhat398
  Indexing [::-1] to Reverse ALL 2D Array Rows, ALL 3D, 4D Array Columns & Rows Python Jeremy7 8 7,244 Mar-02-2021, 01:54 AM
Last Post: Jeremy7
  Deleting employee from list SephMon 3 3,316 Jan-05-2021, 04:15 AM
Last Post: deanhystad
  Counting Element in Multidimensional List quest_ 1 2,152 Nov-25-2020, 10:00 PM
Last Post: quest_
  Choose an element from multidimensional array quest_ 2 2,675 Nov-25-2020, 12:59 AM
Last Post: quest_
  Jelp with a multidimensional loop Formationgrowthhacking 1 1,877 Jan-27-2020, 10:05 PM
Last Post: micseydel
  Sort MULTIDIMENSIONAL Dictionary mirinda 2 4,943 Apr-05-2019, 12:08 PM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020