Changeset 195 for trunk/aeres/scripts
- Timestamp:
- 04/27/12 18:11:05 (12 years ago)
- Location:
- trunk/aeres/scripts
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/aeres/scripts/aeresrh.py
r191 r195 3 3 4 4 __docformat__ = 'reStructuredText' 5 __revision__ = "$Id$" 5 6 __autodoc__ = ['aeresrh'] 7 6 8 7 9 """ … … 67 69 append sur ifiles car liste permanent et liste thesard 68 70 69 comment j'ai la liste des gens partis au 30 juin 2012 avec publication (retraite, decès, mutation) 71 comment j'ai la liste des gens partis au 30 juin 2012 avec 72 publication (retraite, decès, mutation) 70 73 71 74 test with real file (encoding, francais, etc) … … 97 100 - fplod 20120406 98 101 99 * tst avec copie de vrai fichier ( ~/Downloads/personnel\ franc\314\247oise.xlsx)100 dans toto.xsl102 * tst avec copie de vrai fichier 103 (fplod@halios:Downloads/personnel\ franc\314\247oise.xlsx) dans toto.xsl 101 104 - fplod 20120405 102 105 … … 105 108 thanks to http://www.portailsig.org/content/python-lire-et-ecrire-des-fichiers-microsoft-excel-application-quantum-gis 106 109 and http://scienceoss.com/read-excel-files-from-python/ 110 107 111 """ 108 112 … … 141 145 parser.add_option ('-i', '--ifile', 142 146 help='file to be read', 143 147 type='string', 144 148 dest='ifile', 145 149 default=None, 146 150 action='store') 147 151 … … 195 199 for rownum in range(sh.nrows): 196 200 if sh.row_values(rownum)[0] == "Type d'emploi (EC, Ch, AP)": 197 198 if is_verbose == True: 199 201 titlerow = rownum 202 if is_verbose == True: 203 print('titlerow : %d ' % (titlerow)) 200 204 201 205 # deduce first usefull row … … 204 208 # detect last usefull row 205 209 uselessrow = [] 206 for rownum in range(titlerow, sh.nrows):210 for rownum in range(titlerow, sh.nrows): 207 211 if sh.row_values(rownum)[0] == '': 208 212 uselessrow.append(rownum) 209 213 lastrow = uselessrow[0] 210 214 if is_verbose == True: 211 215 print('lastrow : %d ' % (lastrow)) 212 216 213 217 # detect surname column 214 218 for colnum in range(sh.ncols): 215 219 if sh.col_values(colnum)[titlerow] == 'Nom': 216 217 if is_verbose == True: 218 220 colsurname = colnum 221 if is_verbose == True: 222 print('colsurname: %d ' % (colsurname)) 219 223 220 224 # detect firstname column 221 225 for colnum in range(sh.ncols): 222 223 224 if is_verbose == True: 225 226 if sh.col_values(colnum)[titlerow] == u'Prénom': 227 colfirstname = colnum 228 if is_verbose == True: 229 print('colfirstname: %d ' % (colfirstname)) 226 230 227 231 # detect arrival column 228 232 for colnum in range(sh.ncols): 229 230 231 if is_verbose == True: 232 233 if sh.col_values(colnum)[titlerow] == u"Date d'arriv\xe9e dans l'unit\xe9\n(9)": 234 colarrival = colnum 235 if is_verbose == True: 236 print('colarrival: %d ' % (colarrival)) 233 237 234 238 # detect publi column 235 239 for colnum in range(sh.ncols): 236 237 238 if is_verbose == True: 239 240 if sh.col_values(colnum)[titlerow] == u'N\xb0 des 5 productions les plus significatives dans la p\xe9riode \xe9valu\xe9e\n(11)': 241 colpubli = colnum 242 if is_verbose == True: 243 print('colpubli: %d ' % (colpubli)) 240 244 241 245 datemode = 0 … … 244 248 245 249 if is_verbose == True: 246 print(' nb surname %d' % len(surname))247 print(' surname %s' % surname)250 print(' nb surname %d' % len(surname)) 251 print(' surname %s' % surname) 248 252 249 253 firstname = sh.col_values(colfirstname)[firstrow:lastrow] 250 254 251 255 if is_verbose == True: 252 print(' nb firstname %d' % len(firstname))253 print(' firstname %s' % firstname)256 print(' nb firstname %d' % len(firstname)) 257 print(' firstname %s' % firstname) 254 258 255 259 temp = sh.col_values(colarrival)[firstrow:lastrow] … … 261 265 print('eee : pas de date arrivee colonne %d ' % rownum) 262 266 else: 263 arrival.append(datetime.datetime(*xlrd.xldate_as_tuple(temp[rownum], datemode)))264 265 if is_verbose == True: 266 print(' nb arrival %d' % len(arrival))267 print(' arrival %s' % arrival)267 arrival.append(datetime.datetime(*xlrd.xldate_as_tuple(temp[rownum], datemode))) 268 269 if is_verbose == True: 270 print(' nb arrival %d' % len(arrival)) 271 print(' arrival %s' % arrival) 268 272 269 273 publi = sh.col_values(colpubli)[firstrow:lastrow] 270 274 271 275 if is_verbose == True: 272 print(' nb publi %d' % len(publi))273 print(' publi %s' % publi)276 print(' nb publi %d' % len(publi)) 277 print(' publi %s' % publi) 274 278 275 279 return surname, firstname, arrival, publi … … 287 291 ifile = fromcli.ifile 288 292 if fromcli.is_verbose == True: 289 print ('ifile : %s' % (ifile))293 print ('ifile : %s' % (ifile)) 290 294 291 295 surname, firstname, arrival, publi = readrh(ifile, is_verbose) … … 300 304 keys_for_one = ['surname', 'firstname', 'arrival', 'publi'] 301 305 for index in range(len(surname_id)): 302 values_for_one =[]306 values_for_one = [] 303 307 values_for_one.append(surname[index]) 304 308 values_for_one.append(firstname[index]) 305 309 values_for_one.append(arrival[index]) 306 310 values_for_one.append(publi[index]) 307 values_for_all.append(dict(itertools.izip(keys_for_one, values_for_one)))311 values_for_all.append(dict(itertools.izip(keys_for_one, values_for_one))) 308 312 keys_for_all.append('{surname_id}_{firstname_id}'.format(surname_id=surname_id[index], firstname_id=firstname_id[index])) 309 313 … … 316 320 print ('associated info : %s ' % values_for_all[index]) 317 321 318 people = dict(itertools.izip(keys_for_all, values_for_all))322 people = dict(itertools.izip(keys_for_all, values_for_all)) 319 323 320 324 if is_verbose == True: -
trunk/aeres/scripts/build_firstname_id.py
r183 r195 50 50 import re 51 51 52 from unidecode import unidecode 52 try: 53 from unidecode import unidecode 54 except ImportError: 55 print("Failed to import unidecode from any known place") 56 sys.exit(1) 53 57 54 58 def build_firstname_id(firstname): -
trunk/aeres/scripts/build_surname_id.py
r182 r195 51 51 import sys 52 52 53 try: 54 from unidecode import unidecode 55 except ImportError: 56 print("Failed to import unidecode from any known place") 57 sys.exit(1) 58 53 59 def build_surname_id(surname): 54 60 … … 73 79 # convert to str 74 80 surname_str = [str(item) for item in surname] 75 for item in surname:76 print ('iii : item type %s : %s ' % (item, type(item)))81 #for item in surname: 82 # print ('iii : item type %s : %s ' % (item, type(item))) 77 83 78 84 # remove white space before and after -
trunk/aeres/scripts/define_loceanaffectation.py
r181 r195 3 3 4 4 __docformat__ = "restructuredtext en" 5 __revision__ = "$Id$" 6 7 """ 8 =========================== 9 define_loceanaffectation.py 10 =========================== 11 12 DESCRIPTION 13 =========== 14 15 define affectation 16 17 SEE ALSO 18 ======== 19 20 EXAMPLES 21 ======== 22 23 :: 24 25 define_loceanaffectation.py 26 27 28 TODO 29 ==== 30 31 test 32 33 code administration 34 35 coding rules (pylint) 36 37 verbose 38 39 EVOLUTIONS 40 ========== 41 42 $Id$ 43 44 $URL$ 45 46 - fplod 20120427 47 48 * header 49 50 """ 5 51 6 52 def define_loceanaffectation(): … … 29 75 30 76 return affectation_title, affectation_bibtool 77 78 79 # Run main, if called from the command line 80 if __name__ == '__main__': 81 title, bibtool = define_loceanaffectation() 82 print(' title : %s , bibtool : %s' % (title,bibtool)) 83 84
Note: See TracChangeset
for help on using the changeset viewer.