Skip to content

Update library/csv #692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 80 additions & 24 deletions library/csv.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: Python 3.12\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-07-17 17:39+0800\n"
"PO-Revision-Date: 2023-09-10 10:26+0800\n"
"PO-Revision-Date: 2023-11-08 15:06+0800\n"
"Last-Translator: RockLeon <therockleona@gmail.com>\n"
"Language-Team: Chinese - TAIWAN (https://github.com/python/python-docs-zh-"
"tw)\n"
Expand All @@ -17,7 +17,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"X-Generator: Poedit 3.3.2\n"
"X-Generator: Poedit 3.4\n"

#: ../../library/csv.rst:2
msgid ":mod:`csv` --- CSV File Reading and Writing"
Expand Down Expand Up @@ -360,7 +360,7 @@ msgid ""
msgstr ""
"分析給定的 *sample* 且回傳一個 :class:`Dialect` 子類別,反應出找到的格式參"
"數。如果給定選填的參數 *delimiters*,它會被解釋為一個字串且含有可能、有效的分"
"隔字符。"
"隔字元。"

#: ../../library/csv.rst:286
msgid ""
Expand Down Expand Up @@ -507,15 +507,21 @@ msgid ""
"specify individual formatting parameters, which have the same names as the "
"attributes defined below for the :class:`Dialect` class."
msgstr ""
"為了讓指定輸入及輸出紀錄的格式更方便,特定的格式化參數會被組成 dialect。一個 "
"dialect 是 :class:`Dialect` class 的子類別,其有一組特定的方法及單獨的 :meth:"
"`validate` 方法。當建立 :class:`reader` 或 :class:`writer` 物件時,程式設計師"
"可以指定一個字串或是一個 :class:`Dialect` 的子類別作為 dialect 參數。此外,或"
"是作為替代,在\\ *dialect*\\ 參數中,程式設計師可以指定個別的格式化參數,其"
"與 :class:`Dialect` 類別定義的屬性具有相同的名字。"

#: ../../library/csv.rst:382
msgid "Dialects support the following attributes:"
msgstr ""
msgstr "Dialect 支援下列屬性:"

#: ../../library/csv.rst:387
msgid ""
"A one-character string used to separate fields. It defaults to ``','``."
msgstr ""
msgstr "一個單一字元 (one-character) 的字串可已用來分割欄位。預設為 ``','``。"

#: ../../library/csv.rst:392
msgid ""
Expand All @@ -524,12 +530,17 @@ msgid ""
"const:`False`, the *escapechar* is used as a prefix to the *quotechar*. It "
"defaults to :const:`True`."
msgstr ""
"控制 *quotechar* 的實例何時出現在欄位之中,並讓它們自己被放在引號之內。當屬性"
"為 :const:`True`,字元會是雙引號。若為 :const:`False`,在 *quotechar* 之前會"
"先使用 *escapechar* 作為前綴字。預設為 :const:`True`。"

#: ../../library/csv.rst:397
msgid ""
"On output, if *doublequote* is :const:`False` and no *escapechar* is set, :"
"exc:`Error` is raised if a *quotechar* is found in a field."
msgstr ""
"在輸出時,若 *doublequote* 是 :const:`False` 且\\ *逸出字元*\\ 沒有被設定,當"
"一個\\ *引號*\\ 在欄位中被發現時,:exc:`Error` 會被引發。"

#: ../../library/csv.rst:403
msgid ""
Expand All @@ -539,63 +550,79 @@ msgid ""
"from the following character. It defaults to :const:`None`, which disables "
"escaping."
msgstr ""
"一個會被寫入器使用的單一字元的字串,當 *quoting* 設定為 :const:`QUOTE_NONE` "
"時逸出\\ *分隔符號*\\ ;當 *doublequote* 設定為 :const:`False` 時逸出\\ *引號"
"*\\ 。在讀取時,\\ *逸出字元*\\ 會移除後面的字元以及任何特殊意義。預設為 :"
"const:`None`,表示禁止逸出。"

#: ../../library/csv.rst:408
msgid "An empty *escapechar* is not allowed."
msgstr ""
msgstr "*escapechar* 為空是不被接受的。"

#: ../../library/csv.rst:413
msgid ""
"The string used to terminate lines produced by the :class:`writer`. It "
"defaults to ``'\\r\\n'``."
msgstr ""
msgstr "由 :class:`writer` 產生被用來分行的字串。預設為 ``'\\r\\n'``。"

#: ../../library/csv.rst:418
msgid ""
"The :class:`reader` is hard-coded to recognise either ``'\\r'`` or ``'\\n'`` "
"as end-of-line, and ignores *lineterminator*. This behavior may change in "
"the future."
msgstr ""
":class:`reader`是 hard-coded 辨別 ``'\\r'`` or ``'\\n'`` 作為行尾 (end-of-"
"line),並忽略\\ *分行符號*\\ 。未來可能會改變這個行為。"

#: ../../library/csv.rst:425
msgid ""
"A one-character string used to quote fields containing special characters, "
"such as the *delimiter* or *quotechar*, or which contain new-line "
"characters. It defaults to ``'\"'``."
msgstr ""
"一個單一字元的字串被用於引用包含特殊字元的欄位,像是 *delimiter*、"
"*quotechar* 或是換行字元。預設為 ``'\"'``。"

#: ../../library/csv.rst:429
msgid "An empty *quotechar* is not allowed."
msgstr ""
msgstr "*quotechar* 為空是不被允許的。"

#: ../../library/csv.rst:434
msgid ""
"Controls when quotes should be generated by the writer and recognised by the "
"reader. It can take on any of the :const:`QUOTE_\\*` constants (see "
"section :ref:`csv-contents`) and defaults to :const:`QUOTE_MINIMAL`."
msgstr ""
"控制 writer 何時產生引號,以及 reader 如何辨識引號。他可以使用任何 :const:"
"`QUOTE_\\*` 常數(請見段落 :ref:`csv-contents`)且預設為 :const:"
"`QUOTE_MINIMAL`。"

#: ../../library/csv.rst:441
msgid ""
"When :const:`True`, spaces immediately following the *delimiter* are "
"ignored. The default is :const:`False`."
msgstr ""
"若為 :const:`True`,在緊接著\\ *分隔符號*\\ 後的空格會被忽略。預設為 :const:"
"`False`。"

#: ../../library/csv.rst:447
msgid ""
"When ``True``, raise exception :exc:`Error` on bad CSV input. The default is "
"``False``."
msgstr ""
"若為 ``True``,若有錯誤的 CSV 輸入則會引發 :exc:`Error`。預設為 ``False``。"

#: ../../library/csv.rst:451
msgid "Reader Objects"
msgstr ""
msgstr "讀取器物件"

#: ../../library/csv.rst:453
msgid ""
"Reader objects (:class:`DictReader` instances and objects returned by the :"
"func:`reader` function) have the following public methods:"
msgstr ""
"讀取器物件(:func:`reader` 函式回傳的 :class:`DictReader` 實例與物件)有下列"
"公用方法 (public method):"

#: ../../library/csv.rst:458
msgid ""
Expand All @@ -604,34 +631,39 @@ msgid ""
"instance), parsed according to the current :class:`Dialect`. Usually you "
"should call this as ``next(reader)``."
msgstr ""
"回傳一個列表為讀入器的可疊代物件的下一列內容(若該物件是由 :func:`reader` 回"
"傳)或是一個 dict(若為 :class:`DictReader` 實例),會依據當前的 :class:"
"`Dialect` 進行剖析。通常會用 ``next(reader)`` 來進行呼叫。"

#: ../../library/csv.rst:464
msgid "Reader objects have the following public attributes:"
msgstr ""
msgstr "讀取器物件有下列公用屬性 (public attributes):"

#: ../../library/csv.rst:468
msgid "A read-only description of the dialect in use by the parser."
msgstr ""
msgstr "dialect 的唯讀敘述,會被剖析器使用。"

#: ../../library/csv.rst:473
msgid ""
"The number of lines read from the source iterator. This is not the same as "
"the number of records returned, as records can span multiple lines."
msgstr ""
msgstr "來源疊代器所讀取的行數。這與回傳的紀錄數不同,因為可以進行跨行紀錄。"

#: ../../library/csv.rst:477
msgid "DictReader objects have the following public attribute:"
msgstr ""
msgstr "DictReader 物件有下列公用屬性:"

#: ../../library/csv.rst:481
msgid ""
"If not passed as a parameter when creating the object, this attribute is "
"initialized upon first access or when the first record is read from the file."
msgstr ""
"若在建立物件時沒有作為參數傳遞,這個屬性會在第一次存取之前或是第一筆資料被讀"
"取之前進行初始化 (initialize)。"

#: ../../library/csv.rst:488
msgid "Writer Objects"
msgstr ""
msgstr "寫入器物件"

#: ../../library/csv.rst:490
msgid ""
Expand All @@ -644,65 +676,80 @@ msgid ""
"problems for other programs which read CSV files (assuming they support "
"complex numbers at all)."
msgstr ""
":class:`Writer` 物件(:func:`writer` 函式回傳的 :class:`DictWriter` 實例與物"
"件)有下列公用方法。對於 :class:`Writer` 物件而言,一個\\ *列*\\ 中必須為一個"
"可疊代的字串或是數字;對於 :class:`DictWriter` 物件而言,則必須為一個 "
"dictionary ,且可以對應欄位標題至字串或數字(會先透過 :func:`str` 進行傳"
"遞)。請注意,在寫入複數 (complex number) 時會用小括號 (parens) 包起來。這可"
"能在其他程式讀取 CSV 檔案時導致某些問題(假設他們完全支援複雜數字)。"

#: ../../library/csv.rst:501
msgid ""
"Write the *row* parameter to the writer's file object, formatted according "
"to the current :class:`Dialect`. Return the return value of the call to the "
"*write* method of the underlying file object."
msgstr ""
"將參數 *row* 寫入至寫入器的檔案物件中,並依照當前的 :class:`Dialect` 進行格式"
"化。回傳下層檔案物件 *write* 方法的回傳值。"

#: ../../library/csv.rst:505
msgid "Added support of arbitrary iterables."
msgstr "新增對任意 iterable 的支援。"
msgstr "新增對任意可疊代物件 (arbitrary iterables) 的支援。"

#: ../../library/csv.rst:510
msgid ""
"Write all elements in *rows* (an iterable of *row* objects as described "
"above) to the writer's file object, formatted according to the current "
"dialect."
msgstr ""
"將 *rows* 中所有元素(為上述的一個可疊代的 *row* 物件)寫入至寫入器的檔案物件"
"中,並依照當前的 dialect 進行格式化。"

#: ../../library/csv.rst:514
msgid "Writer objects have the following public attribute:"
msgstr ""
msgstr "寫入器物件有下列公用屬性:"

#: ../../library/csv.rst:519
msgid "A read-only description of the dialect in use by the writer."
msgstr ""
msgstr "dialect 的唯讀敘述,會被寫入器使用。"

#: ../../library/csv.rst:522
msgid "DictWriter objects have the following public method:"
msgstr ""
msgstr "DictWriter 物件有下列公用方法:"

#: ../../library/csv.rst:527
msgid ""
"Write a row with the field names (as specified in the constructor) to the "
"writer's file object, formatted according to the current dialect. Return the "
"return value of the :meth:`csvwriter.writerow` call used internally."
msgstr ""
"將具欄位標題的一列(於建構函式 (constructor) 中指定的)寫入至寫入器的檔案物件"
"中,並依照當前的 dialect 進行格式化。回傳內部呼叫 :meth:`csvwriter.writerow` "
"的回傳值。"

#: ../../library/csv.rst:532
msgid ""
":meth:`writeheader` now also returns the value returned by the :meth:"
"`csvwriter.writerow` method it uses internally."
msgstr ""
":meth:`writeheader` 現在也會回傳內部呼叫 :meth:`csvwriter.writerow` 的回傳"
"值。"

#: ../../library/csv.rst:540
msgid "Examples"
msgstr "範例"

#: ../../library/csv.rst:542
msgid "The simplest example of reading a CSV file::"
msgstr ""
msgstr "最簡單的讀取 CSV 檔案範例: ::"

#: ../../library/csv.rst:550
msgid "Reading a file with an alternate format::"
msgstr ""
msgstr "讀取一個其他格式的檔案: ::"

#: ../../library/csv.rst:558
msgid "The corresponding simplest possible writing example is::"
msgstr ""
msgstr "相對最簡單、可行的寫入範例為: ::"

#: ../../library/csv.rst:565
msgid ""
Expand All @@ -711,28 +758,33 @@ msgid ""
"`locale.getencoding`). To decode a file using a different encoding, use the "
"``encoding`` argument of open::"
msgstr ""
"當 :func:`open` 被使用於開啟並讀取一個 CSV 檔案,該檔案會預設使用系統預設的編"
"碼格式(請見 :func:`locale.getencoding`),並解碼為 unicode。若要使用不同編碼"
"格式進行檔案解碼,請使用 open 函式的 ``encoding`` 引數: ::"

#: ../../library/csv.rst:576
msgid ""
"The same applies to writing in something other than the system default "
"encoding: specify the encoding argument when opening the output file."
msgstr ""
"同理可以應用到使用不同編碼格式進行寫入:當開啟輸出檔案時,指定 ``encoding`` "
"引數。"

#: ../../library/csv.rst:579
msgid "Registering a new dialect::"
msgstr ""
msgstr "註冊一個新的 dialect : ::"

#: ../../library/csv.rst:586
msgid ""
"A slightly more advanced use of the reader --- catching and reporting "
"errors::"
msgstr ""
msgstr "稍微進階的讀取器用法 -- 擷取及回報錯誤: ::"

#: ../../library/csv.rst:598
msgid ""
"And while the module doesn't directly support parsing strings, it can easily "
"be done::"
msgstr ""
msgstr "而當模組無法直接支援剖析字串時,仍可以輕鬆的解決: ::"

#: ../../library/csv.rst:607
msgid "Footnotes"
Expand All @@ -746,6 +798,10 @@ msgid ""
"safe to specify ``newline=''``, since the csv module does its own (:term:"
"`universal <universal newlines>`) newline handling."
msgstr ""
"如果 ``newline=''`` 沒有被指定,則嵌入引號中的換行符號不會被正確直譯,使用 "
"``\\r\\n`` 行尾 (linending) 的平台會寫入額外的 ``\\r``。自從 csv 模組有自己 "
"(:term:`統一的 <universal newlines>`) 換行處理方式,因此指定 ``newline=''`` "
"會永遠是安全的。"

#: ../../library/csv.rst:11
msgid "csv"
Expand Down