Sign in to follow this  
Newtothescene

Python script to sort Spotify Family Owners by Countries

Recommended Posts

Instructions to use the script:

This script will split the raw accounts you have to their various country codes, like AU.txt, US.txt, ES.txt, etc

If your accounts come in the format: [email protected]:123456 | AU

You will have to replace the texts using the replace all function, replacing all " | " with " | Country: "

If your account comes in this format, then the US accounts might not be tagged: EG. [email protected] 

What the script will do is to add | Country: US beside the original text

 

Do also make sure that your Accounts.txt does not have any empty linees in between

EG. It can't be

Line 1

 

Line 2

 

It has to be:

Line 1

Line 2

 

If your accounts by default comes with | Country: US 

You do not have to do anything

 

If you execute your script correctly, it will look something like:

Untitled.png

[hide]

with open("Accounts.txt",'r') as f, open("amendedaccounts.txt", 'w') as fw:

        text = f.read()

        text2 = text.split("\n")

        text2str = len(text2)

        i = 0

        while i < text2str:

            if " | " not in text2:

                fw.write(text2 + ' | Country: US\n')

                i += 1

            else:

                fw.write(text2 + '\n')

                i += 1

        f.close()

        fw.close()

 

with open("amendedaccounts.txt",'r') as f:

        text = f.read()

        result_string = ''

        text2 = text.replace("\n\n",'')

        text3 = text2.split("|")

        i = 1

        finaltext = []

        number_of_accounts = str(len(text3))

        print('Number of accounts: ' + number_of_accounts)

        

available_countries = ['AR', 'AT', 'AU', 'BE', 'BG', 'BO', 'BR', 'CA', 'CH', 'CL', 'CO', 'CR', 'CY', 'CZ', 'DE', 'DK', 'DO', 'EC', 'EE', 'ES', 'FI', 'FR', 'GB', 'GR', 'GT', 'HK', 'HN', 'HU', 'ID', 'IE', 'IL', 'IS', 'IT', 'JP', 'LT', 'LU', 'LV', 'MC', 'MT', 'MX', 'MY', 'NI', 'NL', 'NO', 'NZ', 'PA', 'PE', 'PH', 'PL', 'PT', 'PY', 'SE', 'SG', 'SK', 'SV', 'TH', 'TR', 'TW', 'US', 'UY']

c = 0

countries_str = len(available_countries)

while c < countries_str:

    with open("amendedaccounts.txt",'r') as f, open(available_countries[c] + '.txt','w') as fw:

        text = f.read()

        result_string = ''

        country = 'Country: ' + available_countries[c]

        text2 = text.replace("\n\n",'')

        text3 = text2.split("|")

        i = 1

        finaltext = []

        textstr = len(text3)

        if country in text3[1]:

            accountchecker = text3[0].split(':')

            print(text3[0] + ' | ' + available_countries[c]  + ' |')

            fw.write(text3[0] + '\n')

        elif country in (text3[textstr-1]):

            print(text3[textstr-2][13:] + ' | ' + available_countries[c] + ' |')

            fw.write(text3[textstr-2][13:] + '\n')       

        while i < textstr:

            if country in text3:

                text4 = text3[i-1][12:].replace(country,'').replace(' ','').strip()

                accountchecker = text4.split(':')

                fw.write(text4 + '\n')

                print(text4 + ' | ' + available_countries[c]  + ' |')

                i += 1

            elif country not in text3:

                i += 1

                continue

    c += 1[/hide]

Share this post


Link to post
Share on other sites

Instructions to use the script:

This script will split the raw accounts you have to their various country codes, like AU.txt, US.txt, ES.txt, etc

If your accounts come in the format: [email protected]:123456 | AU

You will have to replace the texts using the replace all function, replacing all " | " with " | Country: "

If your account comes in this format, then the US accounts might not be tagged: EG. [email protected] 

What the script will do is to add | Country: US beside the original text

 

Do also make sure that your Accounts.txt does not have any empty linees in between

EG. It can't be

Line 1

 

Line 2

 

It has to be:

Line 1

Line 2

 

If your accounts by default comes with | Country: US 

You do not have to do anything

 

If you execute your script correctly, it will look something like:

Untitled.png

 

:pogchamp: :pogchamp: :??: :??: :??: :??:

Share this post


Link to post
Share on other sites

interesting approach, thanks u for sharing

Share this post


Link to post
Share on other sites

i already made a script like that so it's just to see the code

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this