Home > other >  Some python reads the excel form?
Some python reads the excel form?

Time:09-23



Need to read the work point here A - E, open to point time, this has been read out,
 for I in range (table. Nrows) : 
If (len (table cell (I, 0). The value) & gt; 30) & amp; (i> 1) :
For w in range (table. Nrows) :
H=I + w
If (h> I) & amp; (len (table cell (h, 0) value) & lt; 11) & amp; (len (table cell (h, 0) value) & gt; 3) & amp; (len (table cell (h, 0). The value).=6) :
Table. The cell (h, 0). The value
If a table cell (h, 1). The value is' :
1, table. The cell (h) value=https://bbs.csdn.net/topics/table.cell (h - 1, 2). The value
Print the table cell (h, 0). The value + "" + table. The cell (h - 1, 2). The value
Ws. Write (h, 0, table cell (h, 0) value)
Ws. Write (h, 1, table cell (h - 1, 2). The value)
Wb. Save (' ls a.x)
The else:
Print the table cell (h, 0). The value + "" + table. The cell (h, 1). The value
Ws. Write (h, 0, table cell (h, 0) value)
Ws. Write (h, 1, table cell (h, 1). The value)
Wb. Save (' ls a.x)

However, how to read the right number of total work?
Form in excel location is not fixed, the program through the blue string localization to form,
And the total Numbers of work where a column is not fixed, this how take out 1,5,15,34,110 this data?

CodePudding user response:

List all the data I read
Table. Col_values (I)

Read a grid
Table. The cell (Col, Row). The value the value of the

CodePudding user response:

Get off work combined to which columns

CodePudding user response:

Look for the "total number of work" which is in the cell, and then the cell may account for more than one column, so in this sideways to find rows, until find a number that is the "1,5,15,34,110" after

CodePudding user response:

refer to the second floor uiuiy1 response:
get total number of work for which the column of


Where a column is not sure

CodePudding user response:

There are original content of python tag a

CodePudding user response:

Is to use openpyxl?
Make a transformation:
Def conver_excel_data (data) :
If (data is None) or (datahttps://bbs.csdn.net/topics/=='N/A) or (datahttps://bbs.csdn.net/topics/==' 0 ') or (datahttps://bbs.csdn.net/topics/=='N') or (datahttps://bbs.csdn.net/topics/=='no') :
Return '
The else:
Return the STR (data). Strip ()

While reading the value of the formula:
Open the workbook using data_only=True
Wb=load_workbook (file, read_only=True, data_only=True)

Worksheet is a max_row
Determine a last line not null columns:
Rows=ws1. Max_row - 1
For rx in range (rows) :
Mr_line={}

R_str=ws1. Cell (rx + 11=row, column=11 + b_sel). The value
.


CodePudding user response:

refer to 6th floor mikewolfli response:
is to use openpyxl?
Make a transformation:
Def conver_excel_data (data) :
If (data is None) or (datahttps://bbs.csdn.net/topics/=='N/A) or (datahttps://bbs.csdn.net/topics/==' 0 ') or (datahttps://bbs.csdn.net/topics/=='N') or (datahttps://bbs.csdn.net/topics/=='no') :
Return '
The else:
Return the STR (data). Strip ()

While reading the value of the formula:
Open the workbook using data_only=True
Wb=load_workbook (file, read_only=True, data_only=True)

Worksheet is a max_row
Determine a last line not null columns:
Rows=ws1. Max_row - 1
For rx in range (rows) :
Mr_line={}

R_str=ws1. Cell (rx + 11=row, column=11 + b_sel). The value
.



That if you want to bulk read like a folder, the excel, and excel to do the same to extract data, generating excel
Could you tell me how to implement it in python?

CodePudding user response:

The from OS import listdir
The from OS. Path import isfile, join
F=[f for f in listdir (mypath) if isfile (join (mypath, f)) and f.e ndswith (' XLSX)]

Or:
The from OS import walk

F=[]
For (dirpath, dirnames, filenames) in walk (mypath) :
If filenames. Endswith (' XLSX) :
F.e xtend (filenames)

Then a for loop reads the file list

CodePudding user response:

The original poster behind how to deal with is how to read the right total number from work?
Form in excel location is not fixed, the program through the blue string localization to form,
And the total Numbers of work where a column is not fixed, this how take out 1,5,15,34,110 this data? ?

CodePudding user response:

To read the entire table, find the total that column is the Numbers work

CodePudding user response:

There is a way, is the largest column readout, back minus 1 is the value of that column
  • Related