-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdata_merge_wallets.py
29 lines (23 loc) · 1010 Bytes
/
data_merge_wallets.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import os
import csv
import re
def extract_valid_btc_addresses(folder_path):
btc_addresses = set()
for file_name in os.listdir(folder_path):
if file_name.startswith("col-") or file_name.startswith("src-"):
file_path = os.path.join(folder_path, file_name)
with open(file_path, 'r') as csvfile:
reader = csv.reader(csvfile)
for row in reader:
for address in row:
if re.match(r'^(bc1|[13])[a-zA-HJ-NP-Z0-9]{25,39}$', address):
btc_addresses.add(address)
return list(btc_addresses)
# Folder path to scan for CSV files
folder_path = './collections/'
# Extract valid BTC addresses from CSV files in the specified folder
btc_addresses = extract_valid_btc_addresses(folder_path)
# Write the unique BTC addresses to a new file
with open('./collections/col-MERGED.txt', 'w') as output_file:
for address in btc_addresses:
output_file.write(address + '\n')