Submit
Path:
~
/
/
proc
/
thread-self
/
root
/
proc
/
self
/
root
/
opt
/
alt
/
python27
/
lib64
/
python2.7
/
site-packages
/
mpl_toolkits
/
File Content:
exceltools.pyc
� [�3Lc @ sm d Z d d l Z d d l Z d d l Z d d l j Z d d l j Z d � Z d d d d d d � Z d S( s� Some io tools for excel -- requires xlwt Example usage: import matplotlib.mlab as mlab import mpl_toolkits.exceltools as exceltools r = mlab.csv2rec('somefile.csv', checkrows=0) formatd = dict( weight = mlab.FormatFloat(2), change = mlab.FormatPercent(2), cost = mlab.FormatThousands(2), ) exceltools.rec2excel(r, 'test.xls', formatd=formatd) mlab.rec2csv(r, 'test.csv', formatd=formatd) i����Nc C s� t j | � } t j � } t | t j � re d j d g | j � } d | | f | _ d | _ n� t | t j � r� | j d k r� d j d g | j � } d | | f | _ q� d | _ n$ t | t j � r� d | _ n d } | | _ | S( sn copy the format, perform any overrides, and attach an xlstyle instance copied format is returned t t 0s 0.%s%%;[RED]-0.%s%%g �?i s #,##0.%s;[RED]-#,##0.%ss #,##;[RED]-#,##N( t copyt deepcopyt excelt XFStylet isinstancet mlabt FormatPercentt joint precisiont num_format_strt scalet FormatFloatt FormatIntt Nonet xlstyle( t formatR t zeros( ( sJ /opt/alt/python27/lib64/python2.7/site-packages/mpl_toolkits/exceltools.pyt xlformat_factory s i t NaNt Infc C sz t } t j | � r? | } t j � } | j d � } t } n | d k rW t � } n g } t j � } t | _ t j � } | | _ x� t | j j � D]� \ } } | j | } | j | � } | d k r� t j j | j t j � � } n t | � } | j | | | | | � | j | � q� W| d 7} t j t | j j � � } x| D] } x� | D]� } | | } | | } | j | � } t j | � r�| j | | | | � q_t j | � rt j | � } | d k r�| } n d | } | j | | | | � q_| j d k r1| j | | | | � q_| j | | | | | j � q_W| d 7} qRW| rv| j | � n | S( sv save record array r to excel xlwt worksheet ws starting at rownum. if ws is string like, assume it is a filename and save to it start writing at rownum, colnum formatd is a dictionary mapping dtype name -> mlab.Format instances nanstr is the string that mpl will put into excel for np.nan value The next rownum after writing is returned t worksheeti i s -%sN(! t Falset cbookt is_string_likeR t Workbookt add_sheett TrueR t dictt Fontt boldR t fontt enumeratet dtypet namest getR t defaultformatdt typet FormatObjR t writet appendt npt aranget lent tovalt safe_isnant safe_isinft signR t save( t rt wst formatdt rownumt colnumt nanstrt infstrt autosavet filenamet wbt formatsR t stylehdrt it namet dtR t indt rowt valt sgnt s( ( sJ /opt/alt/python27/lib64/python2.7/site-packages/mpl_toolkits/exceltools.pyt rec2excel<