Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
7424dd35
Kaydet (Commit)
7424dd35
authored
Eki 27, 2010
tarafından
Georg Brandl
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
#5975: add unix_dialect to csv module.
üst
347fe5ce
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
2 deletions
+32
-2
csv.rst
Doc/library/csv.rst
+9
-0
csv.py
Lib/csv.py
+11
-1
test_csv.py
Lib/test/test_csv.py
+9
-0
NEWS
Misc/NEWS
+3
-1
No files found.
Doc/library/csv.rst
Dosyayı görüntüle @
7424dd35
...
...
@@ -187,6 +187,15 @@ The :mod:`csv` module defines the following classes:
TAB-delimited file. It is registered with the dialect name ``'excel-tab'``.
.. class:: unix_dialect()
The :class:`unix_dialect` class defines the usual properties of a CSV file
generated on UNIX systems, i.e. using ``'\n'`` as line terminator and quoting
all fields. It is registered with the dialect name ``'unix'``.
.. versionadded:: 3.2
.. class:: Sniffer()
The :class:`Sniffer` class is used to deduce the format of a CSV file.
...
...
Lib/csv.py
Dosyayı görüntüle @
7424dd35
...
...
@@ -20,7 +20,7 @@ __all__ = [ "QUOTE_MINIMAL", "QUOTE_ALL", "QUOTE_NONNUMERIC", "QUOTE_NONE",
"unregister_dialect"
,
"__version__"
,
"DictReader"
,
"DictWriter"
]
class
Dialect
:
"""Describe a
n Excel
dialect.
"""Describe a
CSV
dialect.
This must be subclassed (see csv.excel). Valid attributes are:
delimiter, quotechar, escapechar, doublequote, skipinitialspace,
...
...
@@ -65,6 +65,16 @@ class excel_tab(excel):
delimiter
=
'
\t
'
register_dialect
(
"excel-tab"
,
excel_tab
)
class
unix_dialect
(
Dialect
):
"""Describe the usual properties of Unix-generated CSV files."""
delimiter
=
','
quotechar
=
'"'
doublequote
=
True
skipinitialspace
=
False
lineterminator
=
'
\n
'
quoting
=
QUOTE_ALL
register_dialect
(
"unix"
,
unix_dialect
)
class
DictReader
:
def
__init__
(
self
,
f
,
fieldnames
=
None
,
restkey
=
None
,
restval
=
None
,
...
...
Lib/test/test_csv.py
Dosyayı görüntüle @
7424dd35
...
...
@@ -515,6 +515,15 @@ class TestEscapedExcel(TestCsvBase):
def
test_read_escape_fieldsep
(
self
):
self
.
readerAssertEqual
(
'abc
\\
,def
\r\n
'
,
[[
'abc,def'
]])
class
TestDialectUnix
(
TestCsvBase
):
dialect
=
'unix'
def
test_simple_writer
(
self
):
self
.
writerAssertEqual
([[
1
,
'abc def'
,
'abc'
]],
'"1","abc def","abc"
\n
'
)
def
test_simple_reader
(
self
):
self
.
readerAssertEqual
(
'"1","abc def","abc"
\n
'
,
[[
'1'
,
'abc def'
,
'abc'
]])
class
QuotedEscapedExcel
(
csv
.
excel
):
quoting
=
csv
.
QUOTE_NONNUMERIC
escapechar
=
'
\\
'
...
...
Misc/NEWS
Dosyayı görüntüle @
7424dd35
...
...
@@ -51,7 +51,9 @@ Core and Builtins
Library
-------
- #7761: telnetlib.interact failures on Windows fixed.
- Issue #5975: Add csv.unix_dialect class.
- Issue #7761: telnetlib.interact failures on Windows fixed.
- logging: Added style option to Formatter to allow %, {} or $-formatting.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment