123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- #Cerca i file relativi alle immagini delle lettere DATINI a partire da CSV e le copia in una nuova directory
- #%%
- import csv
- import os
- import os.path
- import shutil
- output = open('datini_filecodes_complete.csv', 'w')
- csvwriter = csv.writer(output)
- params = ['sigla','segnatura','Fondo','Busta','CODICE','filename_1','filename_2', 'filename_3', 'filename_4', 'filename_5', 'filename_6',
- 'filename_7','filename_8', 'filename_9', 'filename_10', 'filename_11', 'filename_12', 'filename_13','filename_14', 'filename_15', 'filename_16', 'filename_17', 'filename_18',
- 'filename_19','filename_20', 'filename_21', 'filename_22', 'filename_23', 'filename_24', 'filename_25','filename_26', 'filename_27', 'filename_28', 'filename_29', 'filename_30',
- 'filename_31','filename_32', 'filename_33', 'filename_34', 'filename_35', 'filename_36', 'filename_37','filename_38', 'filename_39', 'filename_40']
- csvwriter.writerow(params)
- #%%
- def get_filename (codice, indice):
- filename = codice + indice + ".JPG"
- return filename
- csv_lettere = open('C:\\Users\\OVI-CNR\\Desktop\\Immagini Datini\\estrazione_immagini_complete.csv')
- reader = csv.DictReader(csv_lettere)
- for row in reader:
- line = []
-
- sigla = row['sigla']
- segnatura = row['segnatura']
- fondo = row['Fondo']
- busta = row['Busta']
- codice = row['CODICE']
- filename_1 = get_filename(codice, "01")
- filename_2 = get_filename(codice, "02")
- filename_3 = get_filename(codice, "03")
- filename_4 = get_filename(codice, "04")
- filename_5 = get_filename(codice, "05")
- filename_6 = get_filename(codice, "06")
- filename_7 = get_filename(codice, "07")
- filename_8 = get_filename(codice, "08")
- filename_9 = get_filename(codice, "09")
- filename_10 = get_filename(codice, "10")
- filename_11 = get_filename(codice, "11")
- filename_12 = get_filename(codice, "12")
- filename_13 = get_filename(codice, "13")
- filename_14 = get_filename(codice, "14")
- filename_15 = get_filename(codice, "15")
- filename_16 = get_filename(codice, "16")
- filename_17 = get_filename(codice, "17")
- filename_18 = get_filename(codice, "18")
- filename_19 = get_filename(codice, "19")
- filename_20 = get_filename(codice, "20")
- filename_21 = get_filename(codice, "21")
- filename_22 = get_filename(codice, "22")
- filename_23 = get_filename(codice, "23")
- filename_24 = get_filename(codice, "24")
- filename_25 = get_filename(codice, "25")
- filename_26 = get_filename(codice, "26")
- filename_27 = get_filename(codice, "27")
- filename_28 = get_filename(codice, "28")
- filename_29 = get_filename(codice, "29")
- filename_30 = get_filename(codice, "30")
- filename_31 = get_filename(codice, "31")
- filename_32 = get_filename(codice, "32")
- filename_33 = get_filename(codice, "33")
- filename_34 = get_filename(codice, "34")
- filename_35 = get_filename(codice, "35")
- filename_36 = get_filename(codice, "36")
- filename_37 = get_filename(codice, "37")
- filename_38 = get_filename(codice, "38")
- filename_39 = get_filename(codice, "39")
- filename_40 = get_filename(codice, "40")
- line.append(sigla)
- line.append(segnatura)
- line.append(fondo)
- line.append(busta)
- line.append(codice)
- line.append(filename_1)
- line.append(filename_2)
- line.append(filename_3)
- line.append(filename_4)
- line.append(filename_5)
- line.append(filename_6)
- line.append(filename_7)
- line.append(filename_8)
- line.append(filename_9)
- line.append(filename_10)
- line.append(filename_11)
- line.append(filename_12)
- line.append(filename_13)
- line.append(filename_14)
- line.append(filename_15)
- line.append(filename_16)
- line.append(filename_17)
- line.append(filename_18)
- line.append(filename_19)
- line.append(filename_20)
- line.append(filename_21)
- line.append(filename_22)
- line.append(filename_23)
- line.append(filename_24)
- line.append(filename_25)
- line.append(filename_26)
- line.append(filename_27)
- line.append(filename_28)
- line.append(filename_29)
- line.append(filename_30)
- line.append(filename_31)
- line.append(filename_32)
- line.append(filename_33)
- line.append(filename_34)
- line.append(filename_35)
- line.append(filename_36)
- line.append(filename_37)
- line.append(filename_38)
- line.append(filename_39)
- line.append(filename_40)
- csvwriter.writerow(line)
- output.close()
|