L
L
lyoxamutniy2020-05-13 12:27:17
Python
lyoxamutniy, 2020-05-13 12:27:17

Throws 'invalid syntax' after typing wb_2.save('output.xls'). How to solve the problem?

There is a small program that reads and rewrites a couple of excel files. For some reason it can't save the result. At the very end, wb_2.save('output.xls') is written: python swears at this. I'm a beginner in python, sorry for the restlessness, guru, but I need to finish the course on geodesy. Stuck on this moment. The code:

import xlrd
import xlwt
import math

wb_1 = xlrd.open_workbook('таблица.xlsx', formatting_info=True)
ws_1 = wb_1.sheet_by_name('123')

wb_2 = xlwt.Workbook()
ws_2 = wb_2.add_sheet('вывод')

wb_3 = xlrd.open_workbook('ввод.xlsx')
ws_3 = wb_3.sheet_by_index(0)


degrees = int(input('введите градусы '))
minutes = int(input('введите минуты '))
d = int(input('введите разницу между широтами '))
kol = int(input('введите количество точек '))
Scale = 900000 #нужно вводить, но сейчас лень, еще специально уменьшила на 100 чтобы см не переводить, тоже учесть

      

ws_2.write(0,0,'№')
ws_2.write(0,1,'Lm, м')
ws_2.write(0,2,'lm, см')
ws_2.write(0,3,'m')
ws_2.write(0,4,'Lp, м')
ws_2.write(0,5,'kp, см')
ws_2.write(0,6,'n')
ws_2.write(0,7,'O, град')
ws_2.write(0,8,'A')
ws_2.write(0,9,'B')
ws_2.write(0,10,'a')
ws_2.write(0,11,'b')
ws_2.write(0,12,'p')
ws_2.write(0,13,'w, град')
ws_2.write(0,14,'b, град')
ws_2.write(0,15,'Vm, %')
ws_2.write(0,16,'Vn, %')
ws_2.write(0,17,'Va, %')
ws_2.write(0,18,'Vb, %')
ws_2.write(0,19,'Vp, %')



if minutes == 0:
    j = degrees*2
else:
    j = degrees*2 + 1
    
for k in range(1,kol):
    #переписываю lm из ввода в вывод чтобы было удобнее
        lm = ws_3.row_values(k)[0] 
        ws_2.write(k,2,lm)
    #считаю и записываю Lm     
        val_1 = ws_1.row_values(j)[1]
        j = j + d*2
        val_2 = ws_1.row_values(j)[1]
        L_m = val_2 - val_1
        ws_2.write(k,1,L_m)
    #считаю и записываю m
        m = Scale*lm/L_m
        ws_2.write(k,3,m)      

if minutes == 0:
    j = degrees*2
else:
    j = degrees*2 + 1

for k in range(1,kol):
    #переписываю kp
    kp = ws_3.row_values(k)[1]
    ws_2.write(k,5,kp)
    #Считаю Lp
    val_1 = ws_1.row_values(j)[2]
    j = j + d*2
    L_p = val_1*d*2
    ws_2.write(k,4,L_p)
    #Считаю n
    n = Scale*kp/L_p
    ws_2.write(k,6,n)
    
for k in range (1,kol):
    O = ws_3.row_values(k)[3]
    ws_2.write(k,7,O)
    A = math.sqrt(m2+n2+2*m*n*(math.sin(O)))
    B = math.sqrt(m2+n2-2*m*n*(math.sin(O)))
    a = (A+B)/2
    b = (A-B)/2
    p = ab
    jopa = 2(math.asin((a/b)/(a+b))

wb_2.save('вывод.xls')


5ebbbd5047f5f109986744.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2020-05-13
@lyoxamutniy

error in jopa

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question