You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.0 KiB
40 lines
1.0 KiB
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)))
|