I've been trying to copy a 3D array but it seems like no matter what I do; amending the copy, amends the original as well.
I've tried multiple veriants of the top advice given on this question.
Can anyone explain to me why this code is amending the Clients array, after it's been copied and how to avoid this?
##### This block is to get and save the information
import csv
import datetime
import glob
import os
#import copy
from datetime import timedelta
list_of_files = glob.glob(r'U:\UEL\Sales and Marketing\Relationship - Sales\Team\Edinburgh Clients\Portal backups\Full export archive\*.csv') # * means all if need specific format then *.csv
latest_file = max(list_of_files, key=os.path.getctime)
with open(latest_file, newline='') as csvfile:
data = list(csv.reader(csvfile))
Vheaders = data[0]
data.pop(0)
Clients = list(set(list(zip(*data))[9]))
i = 0
for line in Clients:
Clients[i] = [Clients[i]]
i = i + 1
Voids = []
CoTs = []
for row in Clients:
Voids.append(row)
for row in Clients:
CoTs.append(row)
#Voids = list(Clients) #This creates an array of arrays, an array of voids for each client
#CoTs = list(Voids) #Same as above for CoTs
#import pdb
#pdb.set_trace()
i = 0
for row in Clients:
for line in data:
#if line[0] == '443179':
#import pdb
#pdb.set_trace()
if (datetime.date.today() - timedelta(days=7)) <= datetime.datetime.strptime(line[2], "%d/%m/%Y").date() < datetime.date.today():
if line[9] == row[0]:
Voids[i].append(line)
else:
pass
else:
pass
i = i + 1