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
a978e106
Kaydet (Commit)
a978e106
authored
Mar 21, 2003
tarafından
Andrew M. Kuchling
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add PEP305 section
üst
c71bb97e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
0 deletions
+50
-0
whatsnew23.tex
Doc/whatsnew/whatsnew23.tex
+50
-0
No files found.
Doc/whatsnew/whatsnew23.tex
Dosyayı görüntüle @
a978e106
...
@@ -833,6 +833,56 @@ Implemented by Just van~Rossum.
...
@@ -833,6 +833,56 @@ Implemented by Just van~Rossum.
\end{seealso}
\end{seealso}
%======================================================================
\section
{
PEP 305: Comma-separated Files
\label
{
section-pep305
}}
Comma-separated files are a format frequently used for exporting data
from databases and spreadsheets. Python 2.3 adds a parser for
comma-separated files.
The format is deceptively simple at first glance:
\begin{verbatim}
Costs,150,200,3.95
\end{verbatim}
Read a line and call
\code
{
line.split(',')
}
: what could be simpler?
But toss in string data that can contain commas, and things get more
complicated:
\begin{verbatim}
"Costs",150,200,3.95,"Includes taxes, shipping, and sundry items"
\end{verbatim}
A big ugly regular expression can parse this, but using the new
\module
{
csv
}
package is much simpler:
\begin{verbatim}
from csv import csv
input = open('datafile', 'rb')
reader = csv.reader(input)
for line in reader:
print line
\end{verbatim}
The
\function
{
reader
}
function takes a number of different options.
The field separator isn't limited to the comma and can be changed to
any character, and so can the quoting and line-ending characters.
Different dialects of comma-separated files can be defined and
registered; currently there are two, both for Microsoft Excel.
A separate
\class
{
csv.writer
}
class will generate comma-separated files
from a succession of tuples or lists, quoting strings that contain the
delimiter.
\begin{seealso}
\seepep
{
305
}{
CSV File API
}{
Written and implemented
by Kevin Altis, Dave Cole, Andrew McNamara, Skip Montanaro, Cliff Wells.
}
\end{seealso}
%======================================================================
%======================================================================
\section
{
Extended Slices
\label
{
section-slices
}}
\section
{
Extended Slices
\label
{
section-slices
}}
...
...
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