csv檔案解讀

2021-07-25 05:16:54 字數 935 閱讀 2168

csv格式是分隔的資料格式,有欄位/列分隔的逗號字元和記錄/行分隔換行符。字段包含特殊字元(逗號,換行符,或雙引號),必須以雙引號括住。行內包含乙個專案是空字串,可以以雙引號括住。欄位的值包含雙引號時,要雙寫這個雙引號(就像把乙個雙引號當做轉義符一樣)。csv檔案格式並不需要特定的字元編碼,位元組順序,或行終止格式。

1997,ford,e350

製造商

型號

說明

價值

1997

ford

e350

ac, abs, moon

3000.00

1999

chevy

venture "extended edition"

4900.00

1999

chevy

venture "extended edition, very large"

5000.00

1996

jeep

grand cherokee

must sell!

air, moon roof, loaded

4799.00

上面**內容若以csv格式表示就會像下列:

年,製造商,型號,說明,價值

1997,ford,e350,"ac, abs, moon",3000.00

1999,chevy,"venture ""extended edition""","",4900.00

1999,chevy,"venture ""extended edition, very large""","",5000.00

1996,jeep,grand cherokee,"must sell!

air, moon roof, loaded",4799.00

以上這個csv的例子說明了:

python使用csv寫入csv檔案

沒什麼好說的,直接上 吧 with open file.csv w encoding utf 8 newline as csvfile writer csv.writer csvfile 首先是表頭 writer.writerow id name gender birthday rating 然後是...

python使用csv讀寫CSV檔案

檔案的讀 import csv with open test.csv r as csv file reader csv.reader csv file for line in reader print line 檔案的寫 import csv 表頭 file header houseinfo hou...

寫csv檔案 Python讀寫CSV

逗號分隔值 comma separated values,csv,有時也稱為字元分隔值,因為分隔字元也可以不是逗號 其檔案以純文字形式儲存 資料 數字和文字 1 首先匯入csv模板 2 建立乙個csv檔案物件 3 開啟檔案進行讀取 結果 測試1 軟體測試工程師 測試2 軟體測試工程師 測試3 軟體測...