Avatar
🏃
2 results for Print
  • Je me suis fait des doublons de fichiers dans mes photos, heureusement Python c’est simple et convivial :

    import os
    import sys
    import re
    import PIL
    from PIL import Image
    
    walk_dir = "./Nextcloud/Photos/"
    
    print('walk_dir = ' + walk_dir)
    print('walk_dir (absolute) = ' + os.path.abspath(walk_dir))
    
    for root, subdirs, files in os.walk(walk_dir):
        list_file_path = os.path.join(root, 'my-directory-check.txt')
        print('list_file_path = ' + list_file_path)
        with open(list_file_path, 'wb') as list_file:
            #for subdir in subdirs:
            #   print('\t- subdirectory ' + subdir)
            for filename in files:
                file_path = os.path.join(root, filename)
                # print('\t- file %s (full path: %s)' % (filename, file_path))
                base = os.path.splitext(filename)[0]
                if (base.endswith('_1')):
                        #print('\t- Doublon probable %s %s (full path: %s)' % (filename, base, file_path))
                        double = re.sub('_1$', '', base)
                        double = double + '.jpg'
                        double2 = re.sub('_1$', '', base)
                        double2 = double2 + '.JPG'
                        file_path_double = os.path.join(root, double)
                        file_path_double2 = os.path.join(root, double2)
                        if os.path.isfile(file_path_double):
                            #print('\t- Doublon OK %s & %s' % (file_path, file_path_double))
                            img1 = PIL.Image.open(file_path)
                            img2 = PIL.Image.open(file_path_double)
                            wid1, hgt1 = img1.size 
                            wid2, hgt2 = img2.size 
                            if (wid1 == wid2) and (hgt1 == hgt2):
                                #print('Meme resolution')
                                size1 = os.path.getsize(file_path)
                                size2 = os.path.getsize(file_path_double)
                                if (size1 > size2):
                                        print("%s > %s" % (file_path, file_path_double));
                                        os.remove(file_path_double);
                                else:
                                        print("%s < %s" % (file_path, file_path_double));
                                        os.remove(file_path);
                        elif os.path.isfile(file_path_double2):
                            img1 = PIL.Image.open(file_path)
                            img2 = PIL.Image.open(file_path_double2)
                            wid1, hgt1 = img1.size
                            wid2, hgt2 = img2.size
                            if (wid1 == wid2) and (hgt1 == hgt2):
                                #print('Meme resolution')
                                size1 = os.path.getsize(file_path)
                                size2 = os.path.getsize(file_path_double2)
                                if (size1 > size2):
                                        print("%s > %s" % (file_path, file_path_double2));
                                        os.remove(file_path_double2);
                                else:
                                        print("%s < %s" % (file_path, file_path_double2));
                                        os.remove(file_path);

    Ensuite pour faire un clean des fichiers txt :

    for print Created Mon, 08 Feb 2021 00:00:00 +0000
  • Je viens de faire un nouveau programme en Python afin de mettre les données de ENEDIS sur MariaDB & Python. Pour avoir les données de ENEDIS il faut aller sur https://mon-compte-particulier.enedis.fr/home-connectee/ et se faire un compte. Puis relier ce compte à la facture EDF … Je vais pas vous mentir c’est un peu de parcours du combattant. J’ai du faire appel à plusieurs fois au support afin que le lien puisse se faire. Misère.

    cursor grafana import print row Created Mon, 13 Apr 2020 00:00:00 +0000