Home > other >  Python processing data
Python processing data

Time:11-27

New post for the first time, in fact, the most start learning python is crazy looking at various bosses processing, report a mistake I do not know why, can only be yourself in a way, he himself is really a small white, began to not the sort of,
Mission requirements is 1. 200000 us data to heavy, screening of fault data, (2) through the full text to count, add and subtract the data after averaging, (3) compared with another form of data extraction,
With all the best to understand the method, the easiest way to achieve function,
The import openpyxl
The from openpyxl import Workbook
The from datetime import timedelta

Work_book=openpyxl. Load_workbook (' flight_2017. XLSX) # open file
Sheet=work_book [' flight_2017] # open the form

Nrows=sheet. Max_row # obtained form the number of rows
Ncols=sheet. Max_column # for the column number of the form

Wb=Workbook () #
create tableWs=wb. Active

H=1
For I in range (1, nrows + 1) :
A3=sheet. Cell (row=I, the column=3). The value
A9=sheet. Cell (row=I, the column=9). The value
A6=sheet. Cell (row=I, the column=6). The value
A10=sheet. Cell (row=I, the column=10). The value
A11.=sheet cell (row=I, the column=11). The value
A12=sheet. Cell (row=I, the column=12). The value
A13=sheet. Cell (row=I, the column=13). The value
A14=sheet. Cell (row=I, the column=14). The value
A7.=sheet cell (row=I, the column=7). The value
A8=sheet. Cell (row=I, the column=8). The value
If a3 is None:
# print (" column 3 delete the first line % d % h)
The continue
Elif a9 is None:
# print (" 9 deleted line % d % h)
The continue
Elif a6 is None:
# print (" 6 deleted line % d % h)
The continue
Elif a10 is None:
# print (" 10 deleted line % d % h)
The continue
Elif a11 is None:
# print (" 11 deleted line % d % h)
The continue
Elif a12 is None:
# print (" 12 deleted line % d % h)
The continue
Elif a13 is None:
# print (" 13 deleted line % d % h)
The continue
Elif a14 is None:
# print (" 14 deleted line % d % h)
The continue
Elif i>=2 and a7! A8:
# print (" deleted line % d % I)
The continue
Elif a7 is None:
# print (" 14 deleted line % d % h)
The continue
U=[" plan ", "unknown", "cancel", "being Shadowed", "landing", "not working", "home", "to drop", "delayed"]
If sheet. Cell (row=I, the column=2). The value in u:
The continue
For j in range (1, ncols + 1) :
Cell=sheet. Cell (row=I, the column=j)
M=cell. The value
Ws. Cell (row=h, the column=j, value=https://bbs.csdn.net/topics/m) # will content into another table
H=h + 1
# print (" - "* 10)
Print (" write "a cycle)
Here to go to heavy, filter data is finished, in fact, if can use the or, but don't know why I can't run, I just write it again, all a bit stupid, but useful, ha, ha, ha,
I also see that behind the weight method, but the output data type is not the same, is not convenient behind me, so I gave up, this kind of method is more concise
# to heavy
Lists=[]

Print (type (ws. Max_row))

For li in range (2, ws max_row + 1) :
Lie=ws [li] value
Lists. Append (lie)
Print (lists)
Lists=np. Unique (lists)
Print (type (lists))
Int (lists)
Print (type (lists))

I suddenly found file runs good slow ah, I be silly, a a jump out to, in this way,
  • Related