---
# System prepended metadata

title: 4/11筆記

---

# 4/11筆記

寫入SSV
---

```python=
# 寫入CSV
with open('/content/drive/MyDrive/___TestData/001_Hello.txt', 'w') as f:
  f.write('Hello Google Drive ')
```

(/content/drive/MyDrive/___TestData/)為檔案位置
(001_hello.txt)為副檔案

上列程式碼能在檔案中新增001_Hello.txt
而001_Hello.txt中的內容為(‘Hello Google Drive’)

讀取SSV
---
```python=
with open(‘/content/drive/MyDrive/___TestData//001_Hello.txt’, ‘r’) as f:
ss=f.read()
print(ss)
```
讀取副檔案中的內容

讀取雲端硬碟中的excel檔
---
```python=
import pandas as pd
df = pd.read_excel(‘/content/drive/My Drive/___TestData/001_Income_F.xlsx’)
df
```

讀取硬碟中名為001_Income_F.xlsx的檔案

上載檔案到硬碟
---
```python=
importio
import pandas as pd
from google.colab import files
# 上傳 'opendatal10road.csv' 檔案
uploaded=files.upload()
```

由外部加入檔案到硬碟，成功後檔案會出現在硬碟中

建立表單
---
![](https://i.imgur.com/OunwY9s.png)
![](https://i.imgur.com/FhEFqDs.png)

![](https://i.imgur.com/XN2eqGI.png)

作業一
---
![](https://i.imgur.com/noRFjfB.png)

作業二
---
```
解釋巢狀迴圈
以作業1為例
for i in range(0,5) #ROW
for u in range(0,3) #Column
print(df.iat[i,u])
首先， 將0-5(涵數)放到i(參數) #for i in range(0,5)
由0-5迥圈一次
其次，將0-3(涵數)放到u(參數) #for u in range(0,3)
而df.iat(,)中的i和u為[資料索引值,欄位順序]
即先由ROW中迥圈，再從Column中迥圈出對應該ROW的Value
```