import csv I had to change the length of the csv string during the extremum test. I wish I had done it quickly with EXCEL, but I changed the length of the character string with Python because of my interest. Below is the code
length.py
import csv
import random
#List for output
exp_list = []
max_len = 256
#read csv
with open(r'sample.csv', 'r',encoding='utf-8') as f:
reader = csv.reader(f)
for r in reader:
buff = ''
r_len = len(r[0])
while len(r) < max_len - r_len:
ran = random.randrange(10)
r += str(ran)
for x in r:
buff += x
exp_list.append(buff)
#csv write
with open(r'output.csv', 'w',encoding='utf-8') as f:
writer = csv.writer(f, lineterminator='\n')
writer.writerow(exp_list)
Execution command.txt
python length.py
sample.csv
data1
data2
data3
sample.csv
data198745...
data265644...
data354351...
Recommended Posts