・ Python ・ Sqlite3 ・ Pandas
python
import sqlite3
import pandas as pd
df = pd.read_csv('{csv file path}', encoding='shift-jis')
db_name = 'sample.db' #Create db
conn = sqlite3.connect(db_name) #Connect to db
df.to_sql('class_table', conn, if_exists='replace') #Convert information that captures csv to sql
c = conn.cursor()
query = 'SELECT * FROM class_table'
result = c.execute(query)
c.fetchall() #Get all
for row in result: #Get one by one
print(row)
for vert in range(2, 10): #Get columns in order
vert += 1
for side in range(0, 4):
print(df.loc[vert, side])
side += 1
conn.close() #db disconnect
Recommended Posts