Comparison of common data file formats in Mandarin: Difference between revisions

Created page with "拿到資料檔案該怎麼開?各格式限制與注意事項 == 常見資料格式與限制 == === 1. CSV 檔案 === CSV 檔案:不同欄位值用逗號間隔。 CSV 格式本身沒有筆數上限,限制來自開啟它的軟體。<ref>Row Zero — CSV Row Limits by Spreadsheet: https://rowzero.com/blog/csv-row-limit</ref> 常見問題是 大部分人會使用 Microsoft Excel 開啟 CSV, (1) 中文亂碼:點選兩下發現中文亂碼,檔首需要額外加..."
Tag: wikieditor
 
Tag: wikieditor
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
拿到資料檔案該怎麼開?各格式限制與注意事項
拿到資料檔案該怎麼開?各格式限制與注意事項
{{LanguageSwitcher | content = [[Comparison of common data file formats | EN]], [[Comparison of common data file formats in Mandarin | 漢字]] }}
== 常見格式快速比較表 ==
<table class="wikitable">
    <tr>
        <th>格式</th>
        <th>階層性</th>
        <th>人類易讀</th>
        <th>筆數/容量限制</th>
        <th>常見問題</th>
    </tr>
    <tr>
        <td>'''CSV'''</td>
        <td>無(表格式)</td>
        <td>高</td>
        <td>格式本身無上限,取決於開啟軟體(Excel 約 104 萬列)</td>
        <td>中文亂碼、換行符號欄位值易錯位、數字型別被強制轉換(如電話號碼開頭 0 消失)</td>
    </tr>
    <tr>
        <td>'''TSV'''</td>
        <td>無(表格式)</td>
        <td>高</td>
        <td>同 CSV,格式本身無上限</td>
        <td>與 CSV 相同,但可避免欄位值含逗號時的分隔誤判</td>
    </tr>
    <tr>
        <td>'''Excel'''</td>
        <td>無(表格式)</td>
        <td>高</td>
        <td>理論上限 1,048,576 列 × 16,384 欄;單一儲存格文字上限 32,767 字;超過 10 萬筆操作易頓</td>
        <td>長數字被轉成科學記號、特定字串誤判為日期</td>
    </tr>
    <tr>
        <td>'''JSON'''</td>
        <td>有</td>
        <td>中</td>
        <td>格式本身無筆數上限,瓶頸為讀取時須整檔載入記憶體</td>
        <td>大檔案(如 250MB+)易記憶體不足;建議改用 JSONL 串流讀取</td>
    </tr>
    <tr>
        <td>'''SQLite'''</td>
        <td>無(關聯式)</td>
        <td>低(需工具開啟)</td>
        <td>理論上限 2⁶⁴ 筆,實際受資料庫檔案 281 TB 上限限制(約 2×10¹³ 筆)</td>
        <td>需透過資料庫工具讀寫,不利直接檢視</td>
    </tr>
    <tr>
        <td>'''Parquet'''</td>
        <td>無(欄式)</td>
        <td>低(需工具開啟)</td>
        <td>格式本身無理論筆數上限(以 Row Group 為單位,預設每組 100 萬筆,可有任意組數)</td>
        <td>實務瓶頸為硬碟空間,非格式限制;已有成功案例寫入 5~10 億筆</td>
    </tr>
    <tr>
        <td>'''SQL 檔'''</td>
        <td>無</td>
        <td>中</td>
        <td>純文字格式本身無上限,限制來自匯入工具</td>
        <td>檔案過大時文字編輯器易當機;不同資料庫引擎語法相容性問題</td>
    </tr>
</table>
'''建議:'''
# 需要巢狀/自由格式欄位 → JSON(大量資料改 JSONL)
# 資料量超過百萬筆、只需搬移資料 → Parquet 或 CSV
# 需要還原完整資料庫結構(含關聯、索引) → SQL 或 SQLite
# 一般使用試算表軟體開啟操作 → CSV / Excel,如果要使用 CSV / Excel 顯示階層結構,在欄位名稱可透過分隔符號呈現,例如 {{kbd | key=<nowiki>aaa / bbb</nowiki>}}


== 常見資料格式與限制 ==
== 常見資料格式與限制 ==
Line 45: Line 114:
如果只需要搬移資料而非還原完整資料庫結構,建議改用 CSV 或 Parquet,避免上述相容性問題。
如果只需要搬移資料而非還原完整資料庫結構,建議改用 CSV 或 Parquet,避免上述相容性問題。


== 延伸閱讀 ==
* [http://opendatahandbook.org/guide/zh_TW/appendices/file-formats/ 檔案格式]
* [https://blog.othree.net/log/2016/01/11/json-universe/ JSON Universe : O3noBLOG]
* [[Open_Source_Community#.E9.96.8B.E6.94.BE.E8.B3.87.E6.96.99_.2F_.E5.B7.A8.E9.87.8F.E8.B3.87.E6.96.99|開放資料 相關社群]]
* [https://www.loc.gov/preservation/resources/rfs/TOC.html Recommended Formats Statement – table of contents | Resources (Preservation, Library of Congress)]


== References ==
== References ==