0. ์์ฑ ๋ฐ ๊ธฐ๋ก
import openpyxl
openpyxl ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๋ถ๋ฌ์จ๋ค.
wb = openpyxl.Workbook()
sheet = wb.active
sheet['A1'] = "Type"
sheet['B1'] = "Name"
sheet['C1'] = "Age"
sheet['D1'] = "Fruit"
ํ๋ฅผ ํ๋ ๋ง๋ค๊ณ , A1, B1, C1, D1์ ์์ฑ๊ฐ๋ค์ ๊ธฐ๋กํด์ค๋ค.
TYPE = ['๋ํผ', '์ค๊ณ ์ฐจํ๋งค์', '์นดํ์ฌ์ฅ', ...]
NAME = ['implanted_kid', '์ฐจ์ง์', '์ต์ค', ...]
AGE = [26, 34, 32, ...]
for i in range(2, 2002)
sheet.cell(row=i, column=1).value = TYPE[i]
sheet.cell(row=i, column=2).value = NAME[i]
sheet.cell(row=i, column=3).value = AGE[i]
ํ์ ๊ฐ๋ค์ ๊ธฐ๋ก
wb.save('psick_univ.xlsx')
wb.close()
ํ๋ก ๋ง๋ ๊ฒ๋ค์ ์์ ํ์ผ๋ก ์ ์ฅ
1. ์ฝ์ด์ ์์
wb = openpyxl.load_workbook('psick_univ.xlsx')
last_row = sheet.max_row
์์ ํ์ผ์ ์ด์ด์ ๋ง์ง๋ง ํ์ ์ฐพ๋๋ค.
for i in range(last_row+1, last_row+1 + 200):
...
๋ง์ง๋ง ํ ์ดํ๋ก ๋ฐ์ดํฐ๋ฅผ ์ถ๊ฐํ๋ค. ์ดํ ์ ์ฅํ๊ณ ๋ซ๋ ๊ณผ์ ์ ๊ฐ๋ค.
'๐ป > ํ๋ก๊ทธ๋๋ฐ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[JAVA] ๋์์ธ ํจํด (0) | 2021.09.03 |
---|---|
[ํ์ด์ฌ] ๋ฐฐ์ด ์ธ๋ฑ์ฑ (0) | 2021.04.21 |
[ํ์ด์ฌ] ์ฌ๋ฌ ์นดํ ๊ณ ๋ฆฌ๋ฅผ ์ผ์ ํ๋ฅ ๋ก ์์ฑ (0) | 2021.04.15 |
[C, C++] ๊ณต๋ฐฑ์ด ํฌํจ๋ ๋ฌธ์์ด ์ ๋ ฅ๋ฐ๊ธฐ (0) | 2021.02.20 |
[JAVA] ๊ฐ๋จํ Alphabet Game ๊ตฌํ (0) | 2021.02.04 |