Skip to Content
Bad Data 技術手冊
book

Bad Data 技術手冊

by Q. Ethan McCallum
September 2013
Intermediate to advanced
264 pages
5h
Chinese
GoTop Information, Inc.
Content preview from Bad Data 技術手冊
以檔案為後端的網站框架
|
161
分隔字元
分隔字元在檔案中分隔欄位以及記錄。舉例來說,在一個以逗點分隔的檔案中,新行字
元將記錄分開,而逗點將欄位分開。
在一群問題中要挑選分隔字元遠比想像的要花費精力。我知道有個上線的系統使用四條
槓(
||||
)來分隔字串,藉此來避免修改資料庫綱要以及免除將現有資料修改以跳脫字
元的恐懼。
請對
http://xkcd.com/927/
致敬,ASCII 標準包含了幾乎不曾被使用的分隔字元。ASCII
30 是記錄分隔子,而 ASCII 31 是設計用來分隔欄位的。理論上,讀入這種資料的使用
者系統應該能夠很簡潔的將所有的內容以表格的方式對齊。實際上,就我所知根本沒有
一個使用者系統會支援這種分隔字元,更不用說作出一些對使用者好的事情了。
也許造成不被使用的最大原因是,因為這些分隔字元沒辦法使用鍵盤打出來。CSV 檔案
看起來很醜且不對齊的,但我們都能夠找到逗點這個按鍵。
你最好使用新行來分割記錄,並且使用跳格字元(tab)或是逗點來當作分隔字元。使用
雙引號以及反斜線來當成跳脫字元是很常見的,並且應該很容易在客製的系統中實作。
不管你做什麼,請盡量不要使用很怪的分隔字元。若有人因為「應該不會發生問題」而
推薦你使用
||||
,那麼請告訴他們,使用較常見的標準會較好。
最後,使用空白字元當成分隔字元很容易會造成問題,並且通常都很笨重。在一個越來
越國際化的世界中,空白字元本身已經無法運作。許多亞洲語言並不會使用空白字元來
分隔字元。也許這是個開始思考要使用古老標準的時候了。
以檔案為後端的網站框架 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

RxJava反应式编程

RxJava反应式编程

Tomasz Nurkiewicz, Ben Christensen
高效能PYTHON程式設計

高效能PYTHON程式設計

Micha Gorelick, Ian Ozsvald
Kubernetes编程

Kubernetes编程

Michael Hausenblas, Stefan Schimanski

Publisher Resources

ISBN: 9789862768952