Ñò §ÚêLc@sÆdZddkZddklZddklZlZlZlZl Z l Z l Z l Z l Z lZlZlZlZlZddklZyddklZWn#ej oddklZnXddd d d d d dddddddddddddgZd d"d„ƒYZdefd„ƒYZe deƒdefd„ƒYZe deƒdd#d„ƒYZdd$d „ƒYZyeWnej o eZnXdd%d!„ƒYZdS(&s+ csv.py - read/write/investigate CSV files iÿÿÿÿN(treduce(tErrort __version__twritertreadertregister_dialecttunregister_dialectt get_dialectt list_dialectstfield_size_limitt QUOTE_MINIMALt QUOTE_ALLtQUOTE_NONNUMERICt QUOTE_NONEt__doc__(tDialect(tStringIOR R R R RRRtexcelt excel_tabR RRRRRtSnifferRRt DictReadert DictWritercBsVeZdZdZeZdZdZdZ dZ dZ dZ dZ d„Zd„ZRS(sÇDescribe an Excel dialect. This must be subclassed (see csv.excel). Valid attributes are: delimiter, quotechar, escapechar, doublequote, skipinitialspace, lineterminator, quoting. tcCs+|itjo t|_n|iƒdS(N(t __class__RtTruet_validt _validate(tself((s/usr/lib64/python2.6/csv.pyt__init__-s cCs<yt|ƒWn'tj o}tt|ƒƒ‚nXdS(N(t_Dialectt TypeErrorRtstr(Rte((s/usr/lib64/python2.6/csv.pyR2sN(t__name__t __module__Rt_nametFalseRtNonet delimitert quotechart escapechart doublequotetskipinitialspacetlineterminatortquotingRR(((s/usr/lib64/python2.6/csv.pyRs cBs2eZdZdZdZeZeZdZ e Z RS(s;Describe the usual properties of Excel-generated CSV files.t,t"s ( R!R"RR&R'RR)R$R*R+R R,(((s/usr/lib64/python2.6/csv.pyR9scBseZdZdZRS(sEDescribe the usual properties of Excel-generated TAB-delimited files.s (R!R"RR&(((s/usr/lib64/python2.6/csv.pyRCss excel-tabcBsPeZddddd„Zd„Zed„ƒZeid„ƒZd„ZRS(RcOsI||_||_||_t||||Ž|_||_d|_dS(Ni(t _fieldnamestrestkeytrestvalRtdialecttline_num(Rtft fieldnamesR0R1R2targstkwds((s/usr/lib64/python2.6/csv.pyRJs     cCs|S(N((R((s/usr/lib64/python2.6/csv.pyt__iter__SscCsV|idjo0y|iiƒ|_Wq@tj oq@Xn|ii|_|iS(N(R/R%Rtnextt StopIterationR3(R((s/usr/lib64/python2.6/csv.pyR5Vs cCs ||_dS(N(R/(Rtvalue((s/usr/lib64/python2.6/csv.pyR5`scCsì|idjo |in|iiƒ}|ii|_x!|gjo|iiƒ}q<Wtt|i|ƒƒ}t|iƒ}t|ƒ}||jo||||ieZdZd„Zdd„Zd„Zd„Zd„ZRS(se "Sniffs" the format of a CSV file (i.e. delimiter, quotechar) Returns a Dialect object. cCsdddddg|_dS(NR-s t;t t:(t preferred(R((s/usr/lib64/python2.6/csv.pyR£scCsŽ|i||ƒ\}}}|p|i||ƒ\}}n|p td‚ndtfd„ƒY}||_|pd|_||_|S(sI Returns a dialect (or None) corresponding to the sample sCould not determine delimiterR2cBs eZdZdZeZeZRS(tsniffeds (R!R"R#R+R R,R$R)(((s/usr/lib64/python2.6/csv.pyR2¶sR.(t_guess_quote_and_delimitert_guess_delimiterRRR&R'R*(Rtsamplet delimitersR'R&R*R2((s/usr/lib64/python2.6/csv.pytsniff¨s    c Csüg}xEdD]=}ti|titiBƒ}|i|ƒ}|oPq q W|pdSh}h}d}x |D]} |idd} | | } | o|i| dƒd|| [^\w "'])(?P ?)(?P["']).*?(?P=quote)(?P=delim)sC(?:^| )(?P["']).*?(?P=quote)(?P[^\w "'])(?P ?)sD(?P>[^\w "'])(?P ?)(?P["']).*?(?P=quote)(?:$| )s*(?:^| )(?P["']).*?(?P=quote)(?:$| )RitquoteitdelimtspacecSs ||||jo|p|S(((tatbtquotes((s/usr/lib64/python2.6/csv.pytôscSs ||||jo|p|S(((ReRftdelims((s/usr/lib64/python2.6/csv.pyRhøss (sF(?P[^\w "'])(?P ?)(?P["']).*?(?P=quote)(?P=delim)sC(?:^| )(?P["']).*?(?P=quote)(?P[^\w "'])(?P ?)sD(?P>[^\w "'])(?P ?)(?P["']).*?(?P=quote)(?:$| )s*(?:^| )(?P["']).*?(?P=quote)(?:$| )N(RNi( tretcompiletDOTALLt MULTILINEtfindallR%t groupindexRLtKeyErrorRtkeys(RtdataR`tmatchestrestrtregexpRgRitspacestmtnRCR'RcR*((s/usr/lib64/python2.6/csv.pyR]ÅsZ   !    c Cs1td|idƒƒ}g}tdƒD]}|t|ƒq)~}tdt|ƒƒ}d}h}h} h} dt|t|ƒƒ} } x¢| t|ƒjoŽ|d7}xk|| | !D]\} xS|D]K}|i|hƒ}| i|ƒ}|i|dƒd||<|||RLtcountRqtitemsRtremovetfloatR[tsort(RRrR`RNtctasciit chunkLengtht iterationt charFrequencytmodesRitstarttendtlinetchart metaFrequencytfreqRtmodeListttotalt consistencyt thresholdROtvRcR*R@RQ((s/usr/lib64/python2.6/csv.pyR^s†-  (      "  3 c Cs*tt|ƒ|i|ƒƒ}|iƒ}t|ƒ}h}xt|ƒD]}d||R{R%RqtinttlongRtcomplexRIt OverflowErrorRttypeR( RR_trdrtheadertcolumnst columnTypestitcheckedR?tcoltthisTypet hasHeadertcolType((s/usr/lib64/python2.6/csv.pyt has_headernsX           N( R!R"RRR%RaR]R^R£(((s/usr/lib64/python2.6/csv.pyRžs    @ i((((( RRjt functoolsRt_csvRRRRRRRRR R R R R RRt cStringIORt ImportErrort__all__RRRRR–t NameErrorRR(((s/usr/lib64/python2.6/csv.pyts2 ^     2