I need to copy data from three excel files & paste into three different excel files.
Error:
('F', 'C:\\Users\\jmp655972\\Desktop\\SOFTWARE DEVELOPMENT\\Folder Creation Format\\Base Vehicle Laden\\Steady State\\Continous Test Data\\LH Turn\\test_1.csv')
Pass
('F', 'C:\\Users\\jmp655972\\Desktop\\SOFTWARE DEVELOPMENT\\Folder Creation Format\\Base Vehicle Laden\\Steady State\\Continous Test Data\\LH Turn\\test_2.csv')
Traceback (most recent call last):
File "C:\Users\jmp655972\Desktop\Handling_Analysis_Software\main.py", line 120, in <module>
filescheck(fileCount)
File "C:\Users\jmp655972\Desktop\Handling_Analysis_Software\main.py", line 115, in filescheck
readFilesAndCopyData(excelObj,"roll","1",csvfile)
File "C:\Users\jmp655972\Desktop\Handling_Analysis_Software\main.py", line 62, in readFilesAndCopyData
workbook = excel.Workbooks.Open(filetoOpen)
File "C:\Python27\lib\site-packages\win32com\gen_py\00020813-0000-0000-C000-000000000046x0x1x6.py", line 34940, in Open
, Converter, AddToMru, Local, CorruptLoad)
com_error: (-2147417851, 'The server threw an exception.', None, None
def openExcel():
excel = client.Dispatch("Excel.Application")
excel.Visible = 1
return excel;
def readFilesAndCopyData(excel,testtype,vehicletype,filetoOpen):
currworkingdirectory = os.getcwd()
print ("F",filetoOpen)
workbook = excel.Workbooks.Open(filetoOpen)
worksheets = workbook.Worksheets(1)
if testtype == "roll":
if vehicletype == "1":
print ("Pass")
worksheets.Range("E:E,H:H,I:I").Select()
worksheets.Range("E:E,H:H,I:I").Copy()
else:
worksheets.Range("L:L,O:O,P:P").Select()
worksheets.Range("L:L,O:O,P:P").Copy()
elif testtype == "slip":
if vehicletype == "1":
worksheets.Range("E:E,G:G").Select()
worksheets.Range("E:E,G:G").Copy()
else:
worksheets.Range("E:E,G:G").Select()
worksheets.Range("E:E,G:G").Copy()
else:
print("No Test Data Found")
workbook.Close
pasteCopiedData(excel)
counter + 1