Try to operate an Excel file using Python (Pandas / XlsxWriter) ②

From now on, read Excel files.

There is also a version that reads CSV files.

Click here for file output

reference

Read an Excel file

# import lib
import pandas as pd

# read xlsx file
xlsFile = "hoge.xlsx"
sheetName = "hoge1"
xls_data = pd.read_excel(xlsFile, sheetname=sheetName)
print(xls_data)

Read CSV

# import lib
import pandas as pd

# read csv file
csvFile = "fuga.csv"
csv_data = pd.read_csv(csvFile, encoding='utf-8')
print(csv_data)

bonus

Read the data at the specified position

Column specification

xls_data = pd.read_excel(xlsFile, sheetname="hoge1", parse_cols="A:H")

Line specification

xls_data = pd.read_excel(xlsFile, sheetname="hoge1", skiprows=0, skip_footer=5)

If you want to specify a matrix, you can specify both. It would be nice if it could be specified like ʻA1: H5`, but isn't it possible?

Recommended Posts

Try to operate an Excel file using Python (Pandas / XlsxWriter) ①
Try to operate an Excel file using Python (Pandas / XlsxWriter) ②
Try to operate Excel using Python (Xlwings)
[Python] How to output a pandas table to an excel file
How to read an Excel file (.xlsx) with Pandas [Python]
How to paste a CSV file into an Excel file using Pandas
[Python] How to read excel file with pandas
Try to operate Facebook with Python
Create an Excel file with Python3
Quickly create an excel file with Python #python
[Python] [Excel] Operate an Excel sheet from Python using openpyxl (using a test sheet as an example)
Import Excel file from Python (register to DB)
Try to create an HTTP server using Node.js
Operate Redmine using Python Redmine
Try using Tweepy [Python2.7]
Operate Excel with Python (1)
Operate Excel with Python (2)
Try creating a compressed file using Python and zlib
(Python) Try to develop a web application using Django
Create an image file using PIL (Python Imaging Library).
Try to operate DB with Python and visualize with d3
How to convert JSON file to CSV file with Python Pandas
Type after reading an excel file with pandas read_excel
Try to extract high frequency words using NLTK (python)
Use Pandas to write only the specified lines of the data frame to an excel file
Every time I try to read a csv file using pandas, I get a numpy error.
[Python] You can save an object to a file by using the pickle module.
I get an error when I try to raise Python to 3 series using pyenv on Catalina
Operate Excel with Python openpyxl
Try to make it using GUI and PyQt in Python
Convert from Pandas DataFrame to System.Data.DataTable using Python for .NET
[Python] Convert list to Pandas [Pandas]
[Python] Try using Tkinter's canvas
Try to understand Python self
Try using Kubernetes Client -Python-
Post to Twitter using Python
Start to Selenium using python
Paste the image into an excel file using Python's openpyxl
An introduction to Python Programming
[Python] How to change EXCEL file saved in xlsb to xlsx
[Python Kivy] How to create an exe file with pyinstaller
Data analysis using python pandas
Export pandas dataframe to excel
Try to decipher the garbled attachment file name with Python
Convert Excel file to text in Python for diff purposes
Read the old Gakushin DC application Word file (.doc) from Python and try to operate it.
Process Splunk execution results using Python and save to a file
Try to extract a character string from an image with Python3
Operate Maya from an external Python interpreter using the rpyc module
Try to analyze online family mahjong using Python (PART 1: Take DATA)
Build and try an OpenCV & Python environment in minutes using Docker
Excel file column addition and row deletion processing using Python Openpyxl
Try to operate the database using Python's ORM Peewee (August 2019 version)
Try to log in to Netflix automatically using python on your PC
Python hand play (RDKit descriptor calculation: SDF to CSV using Pandas)
Get the formula in an excel file as a string in Python
Try adding a wall to your IFC file with IfcOpenShell python
Get RSS feed using Python + pandas → Post to Mattermost & Save to DB
[For Python] Quickly create an upload file to AWS Lambda Layer
How to install python using anaconda
[Python] Loading csv files using pandas