Hi,
I want to copy 6th column from csv a to the 6th column in csv b. Besides copying, I want to add three blank rows after the copied one in csv b.
For example, if csv a 6th column has:
Codes:
Thanks for your help! Will do next time
I want to copy 6th column from csv a to the 6th column in csv b. Besides copying, I want to add three blank rows after the copied one in csv b.
For example, if csv a 6th column has:
Output:Event
1
p_o
csv b 6th column should have:Output:1
blank
blank
blank
p_o
blank
blank
blank
My codes copy 6th row in csv a to 4th row in csv b. It also cannot copy any word (e.g. "p_o"), but it can copy number (e.g. 1). Anyone knows how to fix these issues? Or how can I copy specific cell from one csv to the other? I am thinking if I should copy one cell from csv a and three blank cells from csv c to csv b.Codes:
import csv 2 3 def para(session, subj, groupnum): 4 scorefile = str(groupnum) + str('Asns') 5 print("scorefile: %s" % scorefile) 6 scoreart = str(groupnum) + str('AK5s') 7 print("scoreart: %s" % scoreart) 8 9 new_score=r'K:\users\zoey\artscore\\'+scoreart+r'.csv' 10 New_score_csv=open(new_score,'w') 11 12 score_data=r'K:\users\zoey\\'+scorefile+r'.csv' 13 print(score_data) 14 15 with open (score_data) as a, open(new_score,'w') as b: 16 b.write(next(a)) 17 ca=csv.reader(a) 18 ca_rows=list(a) 19 cb=csv.writer(b) 20 21 for row in range(len(ca_rows)): 22 cb.writerow(([" "]*3)+[ca_rows[row][-2]]) # replace -2 with actual col if delimiter is working 23 cb.writerow([" "]*3)
Thanks for your help! Will do next time