I have rar file that contains some data, and I want to make a directory structure out of that and save it in an excel file. I used rarfile library to read the data, but it prints the data out like this
Resources/Custom Brushes/ClothDamageVDM.ZBP, 55.02MB
Resources/Custom Brushes/ControledGravityFolds.ZBP, 0.14MB
Resources/Custom Brushes/GeoStitches.ZBP, 0.06MB
Resources/Custom Brushes/LeatherTexturer.ZBP, 0.23MB
Resources/Custom Brushes/MagicFolds_Hard.ZBP, 5.89MB
Resources/Custom Brushes/MagicFolds_Soft.ZBP, 5.89MB
Resources/Custom Brushes/PreasureSizeFolds.ZBP, 0.07MB
Resources/Custom Brushes/VDM-folds.ZBP, 9.41MB
Resources/Custom Brushes/WovenNanoBrush.ZBP, 0.05MB
Resources/Custom Brushes/Wrinkles_Wrap.ZBP, 0.75MB
Resources/Custom Brushes/Xfolds.ZBP, 0.52MB
Resources/Hotkeys.TXT, 0.0MB
Resources/Masking Alphas/Masking Fold Alpha 01.jpg, 0.29MB
I would like to replace the similar items in these lines with a comma so it is nicely arranged in the excel sheet.
I managed to turn these lines to a list of lists, each list contains the content of the lines separated by the /, now I would like to replace the repeated items with commas, and here is the problem i have encountered.
i wrote the following code to generate a new list populated with commas
original_list= [[1,2,1],[1,2,3],[1,3],[1,3,5]]
# copy a new list
new_list = original_list[:]
for i in range(1, len(new_list)):
# adding the second item in the original list to a set a
a = set(original_list[i])
# adding the first item in the original list to a set b
b = set(original_list[i-1])
# getting the similar items between them in set c
c = list(a.intersection(b))
# for the length of the similar items, go through the new list and change similar items into a ,
for d in range (0, len(c)):
new_list[i][d] = ','
print(original_list)
print(new_list)
#both list are changed
but when I change the new list, the original changes as well. I don't know why when the new list is not a reference, I have used [:] to make sure it is a new list.
I'm quite sure there is a better method to what I am doing overall, so i would appreciate it if you guys can point me in the right direction. right now, I'm stuck at this.
thanks