Esempio n. 1
0
def gpath (path):
    if path:
        path = os.fspath(path)
        fpath = _getfullpathname(path)
        return fpath
    elif isinstance(path,bytes):
        fpath = os.getcwdb()
    else:
        fpath = os.getcwd()
        
    return fpath
Esempio n. 2
0
    _tempfilename = TemporaryFile().name
    proc = Popen(
        'regedit.exe -ea ' + _tempfilename +
        ' "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ProfileList\\"',
        shell=True,
        stdout=PIPE,
        stderr=PIPE)
    proc.wait(1, 5)
    proc.kill
    """
    Корректировка строк во временном файле настроек
    """

    readlines = []
    with open(path._getfullpathname(_tempfilename), 'r+') as fin:
        readlines = fin.readlines()
        readlines_copy = readlines.copy()
        for i in range(len(readlines_copy)):
            if len(readlines_copy[i].strip()
                   ) == 0 or readlines_copy[i].strip()[0] != '[':
                readlines_copy[i] = ''
            else:
                readlines = readlines_copy
                break

    if not len(readlines):
        _print(
            "Нет данных для получения списка пользователей.\nВсего хорошего!\nЗавершение программы...",
            2)
        exit(0)
Esempio n. 3
0
import shutil
PATH = "C:/Users/aksha/Downloads"
os.chdir(PATH)
files = os.listdir(PATH)
for i in files:
    print(i)
rm = input("Files to Del: ")
if rm == "all":
    for j in files:
        os.remove(i)
    sys.exit("Work done")
else:
    rm = rm.split(',')
for r in rm:
    if r in files:
        os.remove(path._getfullpathname(r))
        print(f"{r} is removed succesfully")
    else:
        print(f"file {r} not found Moving on to others")
files = os.listdir(PATH)
if len(files) >= 1:
    for i in files:
        print(i)
    for f in files:
        folder = input(f"where do you want to store {f}: ")
        os.chdir("C:/Users/aksha/Desktop")
        if path.isdir(folder):
            folder_path = path.realpath(folder)
            os.chdir(PATH)
            shutil.move(f, folder_path)
        else:
Esempio n. 4
0
    result = list()
    for r in read_the_folder_for_xlsx():
        wb = load_workbook(r)
        for sheet in wb:
            for i in range(1,sheet.max_row + 1):
                iterator = sheet.cell(row = i, column = search_column)
                if iterator.value == term:
                    result_piece = [sheet.cell(row = i, column = search_column + rel_lookup_column).value, sheet.title, path.basename(r)]
                    result.append(result_piece)
                    print('{}\t{}\t{}'.format(sheet.cell(row = i, column = search_column + rel_lookup_column).value, sheet.title, path.basename(r)))
    return result

def export_results_to_csv(data, dest_filename):
    with open(dest_filename + '.csv', 'a') as the_file:
        for result in data:
            separat = ','
            the_file.write(separat.join(str(x) for x in result) + '\n')
    
def export_results_to_xlsx(data, dest_filename):
    resultswb = Workbook()
    sheet1 = resultswb.active
    sheet1.title = "vlookup results"
    

    resultswb.save(filename = dest_filename)

searchText = input("Search term: ")
result = vlookup_across_multiple_xls(searchText, 2, 2, False)
export_results_to_csv(result, path._getfullpathname(path.curdir) + '\\vlookup_result')
export_results_to_xlsx(result, path._getfullpathname(path.curdir) + '\\vlookup_result')
text = input("Good with this?")