#๐ Check 2 lists for an equal sequence
58 messages ยท Page 1 of 1 (latest)
@stiff wave
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
wtf the bot deleted my whole message because i didnt use syntax?
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
Lesson learned. Don't use discord as a text editor
I have a flightsCSV list a compareList list. I need to find if a sequence on the compare list matches a sequence on the flightsCSV list.
flightsCSV look like this: https://paste.pythondiscord.com/X5XQ
compareList, as an example, looks like this: https://paste.pythondiscord.com/TXEA
There are 2 conditions for matching sequences:
- The sequence can start at any position of compareList but must start at the first entry of CS-0015 in flightsCSV
- The sequence must have at least 3 in a row to be considered a sequence unless there are 3 or less entries of CS-0015 in flightsCSV
*CS-0015 was just an example but could be any CS-XXXX. Although compareList will only contain 1 kind of CS-XXXX at a time
So because of #2, what's the point of compareList being longer than 3 entries?
ok
something like this?
list_of_duplicates = [x for x in flights_csv if x in compare_list]
It filters through each embedded listin flights_csv and checks if it is in the compare list, then saves all that to a list
But that's not looking for an entire sequence though
just single entries that are in both
The 2nd condition is that once the sequence start it must continue until the end of 1 of the lists or both as long as they are the same CS-XXXX
Doesn't matter the size
ok
is the sequence provided?
But the sequence has to be at least 3 long right?
Then my question still is valid - what's the point of the first N-3 entries in compareList?
if the only ones that matter are the last 3
No, could be as small as 1 or as long as the compareList
The sequence will always be in compareList
Might not start at compareList[0]
But will always end at compareList[19]
which is as high as it will go
forgot to mention that
are the entries in compareList always unique?
no
really?
Would just in work then?
If they were, you could just count the number of times compareList[-1] exists in flightsCSV
Ye but the way it's setup there could be duplicates
for example ['CS-009', '98291', '0', '3', '30'] in flightsCSV
what do you mean by that
but there can be duplicates in compareList also though?
yep
Might be easier to understand if I give the actual scenario where that is being used
ok so what about
flightsCSV = [a, b, c, a, b]
compareList = [c, a, b]
What's the "answer" for this scenario?
the sequence would be a,b
because the sequence must always start at the first position of flightsCSV
although compareList could never be smaller than flightsCSV
every message yuo send confuses me even more
Sorry english isn't my first language and I might not explain it clearly
this is false in the example you sent though. flightsCSV is much larger
I thought you were trying to do something else and I understand what you are trying to do now
oh ok, i meant a "sub-list" of only CS-0015
the entries of CS-0015 in flightsCSV could never be smaller than compareList
This is the real scenario:
I'm scrapping a website that has a list.
That list has a limit of 20 rows.
Each new row is added on top, consequently each oldest row is removed from the bottom.
Each time i scrape I retrieve that 20 rows list. Which could be anywhere from 1 row to the full 20 rows.
There is nothing to identify each row in the webiste (no id= or class= or patterns).
!rule 5
5. Do not provide or request help on projects that may violate terms of service, or that may be deemed inappropriate, malicious, or illegal.
Ah no no, it's from a game, the devs actually allow people to do it for spreadsheets and stuff
Oh ok, I would look at zip() in for loops then, it might help
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.