Python Forum
Filter only highest version of list with alpanumeric names
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Filter only highest version of list with alpanumeric names
#1
Hello everyone,

I've have a CSV file with the following documentnames with version (example):

name1.A01
name1.A02
name1.A03
name2.A01
name2.A02
name2.A03
name2.A04
name3.A01
name3.A02
name3.A04
(name3.A03 is not in the list by purpose)

New file should contain:

name1.A03
name2.A04
name3.A04

Anyone an idea how to solve?
Reply
#2
Probably, but what have you thought about?
Reply
#3
(Aug-30-2019, 06:58 PM)Haasje Wrote: Anyone an idea how to solve?

If this is the full description of the task then I would fire up my favorite text editor, enter three lines, save the file and go on with my life.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply
#4
(Aug-30-2019, 07:27 PM)perfringo Wrote:
(Aug-30-2019, 06:58 PM)Haasje Wrote: Anyone an idea how to solve?
If this is the full description of the task then I would fire up my favorite text editor, enter three lines, save the file and go on with my life.

The real file contains 8000 rows ☹️

(Aug-30-2019, 07:00 PM)ndc85430 Wrote: Probably, but what have you thought about?

Hi thanks for your response. I have tried tot solve this with Excel but no success. I got the advice to try this using Python (limited experience with Python).
Reply
#5
In order to write any code one must understand (1) what we have (2) what we want.

As I understand we have file with 8000 rows. We want extract some of these rows. But:

- based on what we want to extract rows (largest version number?)?
- are names sorted by versions as in example (largest version is aways the last)?
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply
#6
(Aug-31-2019, 06:15 AM)perfringo Wrote: In order to write any code one must understand (1) what we have (2) what we want. As I understand we have file with 8000 rows. We want extract some of these rows. But: - based on what we want to extract rows (largest version number?)? - are names sorted by versions as in example (largest version is aways the last)?

1) I want to keep for every document name e.g. name1.Axx only the highest documentname.Axx version. So every documentname is a set of versions A01-Axx but I need only the latest version (combination of documentname.Axx)
2) Names are always sorted as in example. (but not every documentname has always in complete sequence so could be version A01,A02,A04 but also A01, A02 and A05 only).

Thanks in advance for your help.
Reply
#7
Do I understand correctly that there is only one character in versioning and it’s not changing? And within one name versions are sorted.

If so the task is quite simple - iterate over rows and take every row before name change. No need to check version numbers as they are sorted.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Read directory listing of files and parse out the highest number? cubangt 5 2,253 Sep-28-2022, 10:15 PM
Last Post: Larz60+
  Find the highest value of a list Menthix 4 1,835 Oct-29-2021, 02:32 PM
Last Post: Menthix
  Sorting list of names using a lambda (PyBite #5) Drone4four 2 2,683 Oct-16-2020, 07:30 PM
Last Post: ndc85430
  Topic: “Filter numbers with a list comprehension” (PyBite #107) Drone4four 4 2,316 Jun-11-2020, 08:31 PM
Last Post: Drone4four
  List comprehension. Shor for loop version dervast 1 1,565 Dec-11-2019, 12:34 PM
Last Post: perfringo
  Details of attachment files in a msg file such as file names save into a python list klllmmm 2 5,625 Nov-12-2019, 05:59 AM
Last Post: klllmmm
  How to combine file names into a list from multiple directories? python_newbie09 3 5,136 Jul-09-2019, 07:38 PM
Last Post: python_newbie09
  Filter to List and/or Tuple conversion vindo 3 2,714 May-18-2019, 05:40 AM
Last Post: perfringo
  Getting the key for the highest value in a dict - how does this code work? rogfrich 4 3,193 Nov-27-2018, 07:05 PM
Last Post: rogfrich
  2D Array/List OR using variables in other variable names? IAMK 4 3,796 Apr-16-2018, 09:09 PM
Last Post: IAMK

Forum Jump:

User Panel Messages

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