Function to convert Excel column to number

python


def colnum(colname, _A2Z="ABCDEFGHIJKLMNOPQRSTUVWXYZ"):
    result = 0
    for looc, colchar in enumerate(colname[::-1]):
        point = _A2Z.index(colchar)
        result += ((len(_A2Z) ** looc)) * point
    return result

I wrote it because there was no function that returns the numerical value of the column in xlrd that handles Excel with python. If you look closely, it was useless because the corresponding function was included in xlwt. Since xlutils doesn't support python3 yet, You can't edit Excel with python3 using these.

Recommended Posts

Function to convert Excel column to number
Convert json to excel
Convert "number" of excel date to python datetime
Convert Excel data to JSON with python
Convert multiple CSVs to each Excel sheet
Convert to HSV
Convert data with shape (number of data, 1) to (number of data,) with numpy.
Convert UTF-8 CSV files to read in Excel
Convert 202003 to 2020-03 with pandas
Function to return multi columns to single column in DataFrame
Convert kanji to kana
Convert jupyter to py
Convert keras-yolo3 to onnx
Convert dict to array
How to convert Json file to CSV format or EXCEL format
A handy function to add a column anywhere in a Pandas DataFrame
Convert DataFrame column names from Japanese to English using Googletrans
Convert Excel file to text in Python for diff purposes
Convert hexadecimal string to binary
Covector to think in function
[python] Convert date to string
Convert numpy int64 to python int
[Python] Convert list to Pandas [Pandas]
Convert HTML to text file
How to call a function
Add page number to PDF
Convert Scratch project to Python
[Python] Convert Shift_JIS to UTF-8
Convert IP address to decimal
Convert SDF to CSV quickly
Convert genbank file to gff file
Export pandas dataframe to excel
Convert python 3.x code to python 2.x
Convert a large number of PDF files to text files using pdfminer
[Good By Excel] python script to generate sql to convert csv to table