I have a simple csv file with some data as shown:
I'm trying to get my script to read the csv file and generate the barcodes (same file would be idea, but at least if I can get multiple files I can create another script to combine them).
Here is my script:
f = open('bc.csv')
csv_f = csv.reader(f)
next(csv_f)
for serial in csv_f:
data = (''.join(serial))
print(data)
Code39 = barcode.get_barcode_class('code39')
code39 = Code39(data, add_checksum=False)
code39.save('barcodetest')
It runs, but only generates the last code. I know I'm missing something here that will generate multiple files with multiple names, but I am a bit stuck.
CodePudding user response:
You need to differentiate the filename, for example:
f = open('bc.csv')
csv_f = csv.reader(f)
next(csv_f)
for id, serial in enumerate(csv_f):
data = (''.join(serial))
print(data)
Code39 = barcode.get_barcode_class('code39')
code39 = Code39(data, add_checksum=False)
code39.save('barcodetest' str(id))