wrote tool for csv manipulation

master
polymurph 2 years ago
parent 205f151165
commit b11d73a67e

@ -0,0 +1,51 @@
import csv
import os
import sys
def addDatapoint(fifilepathle,datapoint):
with open(filepath, 'a', newline='' ) as f:
writer = csv.writer(f, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
writer.writerow(datapoint)
f.close()
def addDatapoints(filepath,datapoints):
with open(filepath, 'a', newline='' ) as f:
writer = csv.writer(f, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
writer.writerows(datapoints)
f.close()
def createNewCSV(name,fileLocation,header):
filepath = fileLocation + '\\' + name + '.csv'
with open(filepath, 'w', newline='' ) as f:
writer = csv.writer(f, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
writer.writerow(header)
f.close()
return filepath
header = ['x','y']
fileName = 'test'
filepath = os.getcwd() + '\\' + fileName + '.csv'
#os.remove(filepath)
filepath = createNewCSV(fileName,os.getcwd(),header)
print(filepath)
addDatapoint(filepath,(10,10))
addDatapoints(filepath,((1, 2 ),(3, 4)))
'''
with open('test.csv', 'w', newline='' ) as file:
writer = csv.writer(file, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
writer.writerow(header)
file.close()
addDatapoint('test.csv',(10,10))
addDatapoints('test.csv',((1,2),(3,4)))
'''
Loading…
Cancel
Save