-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdateFile.py
More file actions
30 lines (22 loc) · 811 Bytes
/
updateFile.py
File metadata and controls
30 lines (22 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from csv import writer
excelName = "ComapnyDataexample1"
filename = "C:\\Users\\Root\\To\\Excel_File_In_Client_computer\\"+excelName+".csv"
# List
def update(data):
data.sort()
# Open our existing CSV file in append mode
# Create a file object for this file
i = len(data)-1
with open(filename, 'a',newline="") as f_object:
writer_object = writer(f_object)
while i >=0 :
if(i % 2 == 0):
tempdata = [data[i],data[i+1],0]
writer_object.writerow(tempdata)
i = i -1
# Pass this file object to csv.writer()
# and get a writer object
# Pass the list as an argument into
# the writerow()
#Close the file object
f_object.close()