from random import choice from string import ascii_lowercase import ra

 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
30
31
32
33
34
35
36
37
38
39
40
41
42
from random import choice
from string import ascii_lowercase
import random
import csv
from os import path
def generete_mac_id(lenght, count):
mac_ids = []
for _ in range(count):
mac_id = "".join(choice(ascii_lowercase) for _ in range(lenght))
mac_ids.append(mac_id)
return mac_ids
def generete_input(input_file, mac_count, ding_count, mac_length, ding_lenght):
with open(input_file, 'a') as input:
input.write(f'mac_id, ding_id\n')
mac_ids = generete_mac_id(mac_length, mac_count)
for _ in range(ding_count):
ding_id = "".join(str((random.randint(0, 9))) for _ in range(ding_lenght))
input.write(f'{random.choice(mac_ids)}, {ding_id}\n')
def generete_output(input_file):
with open(input_file, "r") as input:
csv_file = csv.reader(input, delimiter=",")
line_count = 0
for row in csv_file:
if line_count == 0:
line_count += 1
continue
line_count += 1
filename = f'{row[0]}.txt'
if path.exists(filename):
with open(filename, "a") as output:
output.write(f'{row[1]}\n')
else:
with open(filename, "a") as output:
output.write(f'{row[1]}\n')
generete_input('input.csv', 3, 20, 5, 10)
generete_output('input.csv')