ronnie
2022-10-14 1504bb53e29d3d46222c0b3ea994fc494b48e153
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
L\¬Qc@sÂdZddlZddlmZddlmZmZmZmZm    Z    m
Z
m Z m Z m Z mZmZmZmZmZddlmZyddlmZWn!ek
rÇddlmZnXddd    d
d d d dddddddddddddgZd d"d„ƒYZdefd„ƒYZe    deƒdefd„ƒYZe    deƒdd#d„ƒYZdd$d „ƒYZyeWnek
rª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)|jtkrt|_n|jƒdS(N(t    __class__RtTruet_validt    _validate(tself((sK/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/csv.pyt__init__-s cCs:yt|ƒWn%tk
r5}tt|ƒƒ‚nXdS(N(t_Dialectt    TypeErrorRtstr(Rte((sK/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/csv.pyR2sN(t__name__t
__module__Rt_nametFalseRtNonet    delimitert    quotechart
escapechart doublequotetskipinitialspacetlineterminatortquotingRR(((sK/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/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,(((sK/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/csv.pyR9scBseZdZdZRS(sEDescribe the usual properties of Excel-generated TAB-delimited files.s    (R!R"RR&(((sK/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/csv.pyRCss    excel-tabcBsPeZddddd„Zd„Zed„ƒZejd„ƒZd„ZRS(RcOsI||_||_||_t||||Ž|_||_d|_dS(Ni(t _fieldnamestrestkeytrestvalRtdialecttline_num(Rtft
fieldnamesR0R1R2targstkwds((sK/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/csv.pyRJs                 cCs|S(N((R((sK/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/csv.pyt__iter__SscCsR|jdkr<y|jjƒ|_Wq<tk
r8q<Xn|jj|_|jS(N(R/R%Rtnextt StopIterationR3(R((sK/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/csv.pyR5Vs cCs ||_dS(N(R/(Rtvalue((sK/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/csv.pyR5`scCsä|jdkr|jn|jjƒ}|jj|_x|gkrX|jjƒ}q:Wtt|j|ƒƒ}t|jƒ}t|ƒ}||kr¬||||j<n4||kràx%|j|D]}|j||<qÆWn|S(Ni(    R3R5RR9tdicttziptlenR0R1(Rtrowtdtlftlrtkey((sK/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/csv.pyR9ds
   N(    R!R"R%RR8tpropertyR5tsetterR9(((sK/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/csv.pyRIs          
cBs>eZdddd„Zd„Zd„Zd„Zd„ZRS(RtraiseRcOsY||_||_|jƒdkr4td|‚n||_t||||Ž|_dS(NRFtignores-extrasaction (%s) must be 'raise' or 'ignore'(RFsignore(R5R1tlowert
ValueErrort extrasactionR(RR4R5R1RJR2R6R7((sK/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/csv.pyR|s        
    cCs,tt|j|jƒƒ}|j|ƒdS(N(R<R=R5twriterow(Rtheader((sK/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/csv.pyt writeheader‡scCs…|jdkr\g|D]}||jkr|^q}|r\tddj|ƒƒ‚q\ng|jD]}|j||jƒ^qfS(NRFs(dict contains fields not in fieldnames: s, (RJR5RItjointgetR1(Rtrowdicttkt wrong_fieldsRC((sK/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/csv.pyt _dict_to_list‹s (cCs|jj|j|ƒƒS(N(RRKRS(RRP((sK/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/csv.pyRK“scCs=g}x$|D]}|j|j|ƒƒq W|jj|ƒS(N(tappendRSRt    writerows(RtrowdictstrowsRP((sK/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/csv.pyRU–s (R!R"RRMRSRKRU(((sK/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/csv.pyR{s 
           cBs>eZdZd„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((sK/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/csv.pyR§scCs•|j||ƒ\}}}}|s?|j||ƒ\}}n|sQtd‚ndtfd„ƒY}||_||_|p‚d|_||_|S(sI
        Returns a dialect (or None) corresponding to the sample
        sCould not determine delimiterR2cBseZdZdZeZRS(tsniffeds
(R!R"R#R+R
R,(((sK/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/csv.pyR2ºsR.(t_guess_quote_and_delimitert_guess_delimiterRRR)R&R'R*(Rtsamplet
delimitersR'R)R&R*R2((sK/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/csv.pytsniff¬s                 cCs<g}xCdD];}tj|tjtjBƒ}|j|ƒ}|r Pq q W|sbdtddfSi}i}d}x|D]ø}    |jdd}
|    |
} | r¿|j| dƒd|| <ny|jd    d}
|    |
} Wnt    k
rôq{nX| r0|dks| |kr0|j| dƒd|| <ny|jd
d}
Wnt    k
r[q{nX|    |
r{|d7}q{q{Wt
|d „|j ƒƒ} |rÛt
|d „|j ƒƒ} || |k}| d krçd} qçn d} d}tjdi| d    6| d6tjƒ}|j |ƒr&t }nt}| || |fS(s
        Looks for text enclosed between two identical quotes
        (the probable quotechar) which are preceded and followed
        by the same character (the probable delimiter).
        For example:
                         ,'some text',
        The quote with the most wins, same with the delimiter.
        If there is no quotechar the delimiter can't be determined
        this way.
        sF(?P<delim>[^\w
"'])(?P<space> ?)(?P<quote>["']).*?(?P=quote)(?P=delim)sC(?:^|
)(?P<quote>["']).*?(?P=quote)(?P<delim>[^\w
"'])(?P<space> ?)sD(?P<delim>>[^\w
"'])(?P<space> ?)(?P<quote>["']).*?(?P=quote)(?:$|
)s*(?:^|
)(?P<quote>["']).*?(?P=quote)(?:$|
)RitquoteitdelimtspacecSs||||kr|p|S(N((tatbtquotes((sK/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/csv.pyt<lambda>øscSs||||kr|p|S(N((ReRftdelims((sK/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/csv.pyRhüss
s]((%(delim)s)|^)\W*%(quote)s[^%(delim)s\n]*%(quote)s[^%(delim)s\n]*%(quote)s\W*((%(delim)s)|$)(sF(?P<delim>[^\w
"'])(?P<space> ?)(?P<quote>["']).*?(?P=quote)(?P=delim)sC(?:^|
)(?P<quote>["']).*?(?P=quote)(?P<delim>[^\w
"'])(?P<space> ?)sD(?P<delim>>[^\w
"'])(?P<space> ?)(?P<quote>["']).*?(?P=quote)(?:$|
)s*(?:^|
)(?P<quote>["']).*?(?P=quote)(?:$|
)N(tretcompiletDOTALLt    MULTILINEtfindallR$R%t
groupindexROtKeyErrorRtkeystsearchR(RtdataR`tmatchestrestrtregexpRgRitspacestmtnRCR'RcR*t    dq_regexpR)((sK/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/csv.pyR]És` 
 
 
            cCstd|jdƒƒ}gtdƒD]}t|ƒ^q%}tdt|ƒƒ}d}i}i}i}    dt|t|ƒƒ}
} x|
t|ƒkr|d7}xk||
| !D]\} xS|D]K} |j| iƒ}| j| ƒ}|j|dƒd||<||| <qÀWq³WxÎ|j    ƒD]À} || j
ƒ}t|ƒdkrb|dddkrbq nt|ƒdkrÒt d„|ƒ|| <|j || ƒ|| d|| dt d„|ƒdf|| <q |d|| <q W|j
ƒ}t ||ƒ}d}d    }xŸt|    ƒdkr­||kr­xp|D]h\}}|ddkr4|ddkr4|d||krœ|dksŒ||krœ||    |<qœq4q4W|d
8}qWt|    ƒdkr|    j    ƒd}|dj|ƒ|djd |ƒk}||fS| }
| |7} q‰W|    s"dSt|    ƒdkr‘xZ|jD]L}||    j    ƒkr>|dj|ƒ|djd |ƒk}||fSq>Wng|    j
ƒD]\}}||f^qž}|jƒ|d d}|dj|ƒ|djd |ƒk}||fS(s½
        The delimiter /should/ occur the same number of times on
        each row. However, due to malformed data, it may not. We don't want
        an all or nothing approach, so we allow for small variations in this
        number.
          1) build a table of the frequency of each character on every line.
          2) build a table of frequencies of this frequency (meta-frequency?),
             e.g.  'x occurred 5 times in 10 rows, 6 times in 1000 rows,
             7 times in 2 rows'
          3) use the mode of the meta-frequency to determine the /expected/
             frequency for that character
          4) find out how often the character actually meets that goal
          5) the character that best meets its goal is the delimiter
        For performance reasons, the data is evaluated in chunks, so it can
        try and evaluate the smallest portion of the data possible, evaluating
        additional chunks as necessary.
        s
ii
iicSs|d|dkr|p|S(Ni((ReRf((sK/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/csv.pyRhDscSsd|d|dfS(Nii((ReRf((sK/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/csv.pyRhJsgð?gÍÌÌÌÌÌì?g{®Gáz„?s%c RiÿÿÿÿN(Ri(tfilterR%tsplittrangetchrtminR>ROtcountRqtitemsRtremovetfloatR[tsort(RRsR`tctasciit chunkLengtht    iterationt charFrequencytmodesRitstarttendtlinetchart metaFrequencytfreqRtmodeListttotalt consistencyt    thresholdRQtvRcR*R@((sK/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/csv.pyR^sx%
 &          ! 
+
c    Cstt|ƒ|j|ƒƒ}|jƒ}t|ƒ}i}xt|ƒD]}d||<qIWd}xý|D]õ}|dkr€Pn|d7}t|ƒ|kr¢qjnxº|jƒD]¬}    xWtt    t
t gD]3}
y|
||    ƒPWqÈt t fk
rúqÈXqÈWt||    ƒ}
|
t    kr$t}
n|
||    kr¯||    dkrQ|
||    <q[||    =q¯q¯WqjWd} x¢|jƒD]”\}    } t| ƒtdƒkrÊt||    ƒ| kr½| d7} q
| d8} qvy| ||    ƒWn!t tfk
rÿ| d7} qvX| d8} qvW| dkS(Niii(RRRaR9R>R}R%RqtinttlongRƒtcomplexRIt OverflowErrorRttypeR( RR_trdrRLtcolumnst columnTypestitcheckedR?tcoltthisTypet    hasHeadertcolType((sK/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/csv.pyt
has_header~sN
 
        N(    R!R"RRR%RaR]R^R¤(((sK/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/csv.pyR¢s          L    i((((( RRjt    functoolsRt_csvRRRRRRRRR    R
R R R RRt    cStringIORt ImportErrort__all__RRRRR˜t    NameErrorRƒR(((sK/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/csv.pyt<module>s2 ^         2"