Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import csv
- def list_txt_files(folder):
- """List all .txt files in a folder."""
- return [f for f in os.listdir(folder) if f.endswith('.txt')]
- def read_file(file_path):
- """Read lines from a file."""
- with open(file_path, 'r') as file:
- return file.readlines()
- def write_csv(file_path, rows, header):
- """Write rows to a CSV file."""
- with open(file_path, 'w', newline='') as file:
- writer = csv.writer(file)
- writer.writerow(header)
- writer.writerows(rows)
- def main():
- # List available files
- txt_files = list_txt_files('.')
- if not txt_files:
- print("No .txt files found in the current directory.")
- return
- print("Available .txt files:")
- for i, file in enumerate(txt_files, 1):
- print(f"{i}. {file}")
- # Choose the accounts file
- acc_file_index = int(input("Choose the file that contains the accounts (type in the number associated with a file and press Enter): ")) - 1
- accounts_file = txt_files[acc_file_index]
- accounts = read_file(accounts_file)
- # Choose the proxies file
- proxy_file_index = int(input("Choose the proxy .txt file (format proxyip:port,username,password): ")) - 1
- proxies_file = txt_files[proxy_file_index]
- proxies = read_file(proxies_file)
- # Parse proxies
- proxies = [proxy.strip().split(',') for proxy in proxies]
- proxy_count = len(proxies)
- if proxy_count == 0:
- print("No valid proxies found in the proxies file.")
- return
- # Define CSV header
- header = [
- "name", "email/username", "password", "proxy-url/proxy-ip:port",
- "proxy username", "proxy password", "tags", "date of birth (US format)",
- "description", "unique name", "email validation username",
- "email validation pass", "email validation pop3server", "email validation port",
- "EB user agent", "api user agent", "username", "platform", "Notes",
- "ApiCookies", "Phone Number", "2FA Secret Key"
- ]
- # Ask for the number of accounts per proxy
- accounts_per_proxy = int(input("Enter how many accounts will use the same proxy: "))
- # Replace proxies in accounts and prepare CSV rows
- rows = []
- proxy_index = 0
- for i, account in enumerate(accounts):
- if "#proxy-url/proxy-ip:port" in account:
- # Determine the proxy to use based on accounts_per_proxy
- proxy = proxies[proxy_index % proxy_count]
- proxy_str = f"{proxy[0]},{proxy[1]},{proxy[2]}"
- account = account.replace("#proxy-url/proxy-ip:port,#proxy username,#proxy password", proxy_str)
- # Increment proxy index only after `accounts_per_proxy` accounts have been assigned the same proxy
- if (i + 1) % accounts_per_proxy == 0:
- proxy_index += 1
- # Split account data by comma and add to rows
- rows.append(account.strip().split(','))
- # Save to CSV file
- output_file = "output.csv"
- write_csv(output_file, rows, header)
- print(f"Updated accounts have been saved to {output_file} as a CSV file. Ready to import to Jarvee/Susocial")
- if __name__ == "__main__":
- try:
- main()
- except Exception as e:
- print(f"An error occurred: {e}")
- finally:
- input("Press Enter to exit...")
Advertisement
Add Comment
Please, Sign In to add comment