Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LPA pokemon moves #1132

Closed

Conversation

programgames
Copy link
Contributor

Hello,
I scraped pokemon moves from the Legend Pokemon Arceus version group from https://www.serebii.net/ .
There is the file i generated :
lpa.csv
I wanted to make a fusion of this with the original file using a little script without adding all the data at the end of the file.
So i tried to understand how this file is sorted and I tought that the data was sorted using colums ( in this order ) :
pokemon_id, move_id, pokemon_move_method_id, level

So I created this little script :

import csv
import os

csv_file = 'lpa.csv'

out = []
print(os.getcwd())

with open(csv_file, newline='', encoding='utf-8') as file:
    reader = csv.reader(file)

    for row in reader:
        if row[0] == 'pokemon_id':
            continue
        out.append([row[0], row[1], row[2],row[3],row[4],row[5],row[6]])


csv_file2 = 'original.csv'

with open(csv_file2, newline='', encoding='utf-8') as file2:
    reader = csv.DictReader(file2)

    for ligne in reader:
        out.append([ligne['pokemon_id'], ligne['version_group_id'], ligne['move_id'],ligne['pokemon_move_method_id'],ligne['level'],ligne['order']])

sorted_data = sorted(out, key=lambda x: (int(x[0]), int(x[1]), int(x[3]),int(x[4])))

with open('reunited.csv', mode='w', newline='', encoding='utf-8') as file:
    writer = csv.writer(file)

    writer.writerow(['pokemon_id','version_group_id','move_id','pokemon_move_method_id','level','order','mastery'])
    for row in sorted_data:
        writer.writerow(row)

But as you can see in the new file generated, lpa mooves seems to be inserted in the good places, but some old mooves are mooved. Do you have an idea ? Or a better way to just insert new data ?

@programgames
Copy link
Contributor Author

A good example of what happened : image

@Naramsim
Copy link
Member

Naramsim commented Oct 5, 2024

Hi @programgames, thanks for the PR. Could you please run black . on your branch and push again?

@Naramsim
Copy link
Member

Naramsim commented Oct 9, 2024

@programgames I've checked out locally your PR. I think the sorting isn't a problem. So since there are some conflicts with the master branch I'd ask you to rerun the script on the new master data and then force-push or reopen another pull request.

@programgames
Copy link
Contributor Author

Ok CI is running #1149

@Naramsim Naramsim closed this Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants