Hi,
I am using the following code to export a CSV file. But it is not copying sometimes and running too long without exit and halt the whole tag change script even i cancelled the running query. It will back to normal only gateway restarts
def CreateRecordCSV(job, serial):
import os.path
import datetime
import shutil
localPath = 'R:/OracleIgnition/'
remotePath = 'Z:/'
timestamp = ''
fileName = ''
d = datetime.datetime.today()
_params = {}
_params['day'] = d.strftime('%d')
_params['month'] = d.strftime('%b').upper()
_params['year'] = d.strftime('%Y')
_params['hour'] = d.strftime('%H')
_params['minute'] = d.strftime('%M')
_params['second'] = d.strftime('%S')
_params['mili'] = d.strftime('%f')[:3]
_params['mon'] = d.strftime('%m')
timestamp = _params['day'] + '-' + _params['month'] + '-' + _params['year'] + ' ' + _params['hour'] + ':' + _params['minute'] + ':' + _params['second']
fileName = 'ignition_' + _params['year'] + _params['mon'] + _params['day'] + _params['hour'] + _params['minute'] + _params['second'] + _params['mili']
import csv
data = [job, serial, timestamp]
completeLocal = os.path.join(localPath, fileName+".csv")
with open(completeLocal, 'w+') as f:
writer = csv.writer(f)
writer.writerow(data)
# Copy to Oracle server
completeRemote = os.path.join(remotePath, fileName+".csv")
shutil.copy(completeLocal, completeRemote)
Could you please someone help me