I came up with this it is not tested I don’t do python
import csv
# Initialize a list to store the ASNs
asns = []
# Open the CSV file
with open('your_file.csv', 'r') as csvfile:
# Create a CSV reader
csvreader = csv.reader(csvfile)
# Skip the header row
next(csvreader)
# Iterate through the rows in the CSV file
for row in csvreader:
# Extract the ASN from the 'asn' column (assuming it's in the 3rd column, index 2)
asn = row[2]
# Append the ASN to the list
asns.append(asn)
# Define the path to the text file where you want to save the ASNs
output_file = 'asns.txt'
# Write the ASNs to the text file
with open(output_file, 'w') as txtfile:
for asn in asns:
txtfile.write(asn + '\n')
print(f"ASNs have been saved to {output_file}")