I started learning Python. I'm thinking of studying almost on my own. Those who want to see it are as the title. In this article, I would like to post articles and sites that I referred to. (Updated 3/3/2020)
If you look into it, there are many modules that process like Excel VBA. It is shown below. I tried various things, but in the end I thought that only pandas would be enough. Please let me know if there is any advantage to using other modules.
qiita.py
import csv
import openpyxl
import pandas as pd
First, open the csv file. I think you can also go with numpy. I will omit the result.
qiita.py
import pandas as pd
with open('Desktop/test.csv', encoding="utf-8") as f:
for row in f:
print(row)
or
import pandas as pd
with open('Desktop/test.csv', encoding="utf-8") as f:
print(f.read())
It is convenient to use skiprows and usecols when reading because the data can be formatted. I think it's a good idea to monitor the data you want to extract while looking at print ().
qiita.py
import pandas as pd
data = pd.read_csv("Desktop/test.csv", encoding="utf-8", skiprows=259, usecols=[1,6])
print(data)
data.to_csv("Desktop/test.csv")
Recommended Posts