The Computer Oracle

How to edit Excel file (xlsx) using linux shell

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: The World Wide Mind

--

Chapters
00:00 How To Edit Excel File (Xlsx) Using Linux Shell
00:28 Accepted Answer Score 14
00:42 Thank you

--

Full question
https://superuser.com/questions/1337957/...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#linux #microsoftexcel #shell #shellscript

#avk47



ACCEPTED ANSWER

Score 14


My idea is a python script like this:

import pandas as pd
filename=argv[1]
df = pd.read_excel(filename,sheet_name="Sheet1").ix[:-3] ## read the xlsx without last 3 rows to a dataframe
df.write_excel("output_sheet.xlsx") #write dataframe to xlsx file

to check "non-emptiness" you can use df.notna()