не находит каталог или файл в azure в python - PullRequest
0 голосов
/ 26 марта 2020

Я сделал скрипт в python, локально успешно выполнен, но в azure не нашел пути, я провел тест с pyspark просто чтобы посмотреть, нашел ли он путь и нашел, но я не знаю pyspark, чтобы превратить этот код в pyspark, как мне получить доступ к каталогу в azure?

import csv
from datetime import datetime


origem  ='/mnt/caminho/teste.txt'
destino = "/mnt/caminho/teste.csv"

print(origem)
print(destino)

try:
    with open(origem, "r", encoding="UTF-8") as ler, open(destino, mode='w', encoding='UTF-8') as gravar:
        next(ler)
        next(ler)
        gravar.writelines(['data_puxada;','centro;','atribuicao;','ped_pca;','transporte;','fornecimento;','codigo_material;','descr_produto;','descr_status_pedido;','quantidade;','hora_puxada;','cliente;','cliente_sap;','numero_nota_fiscal;','data_inicio_carregamento;','hora_inicio_carregamento;','dt_termino_carregamento;','hora_termino_carregamento;','numeroov_pedtransf;','can_distrib;','tipo_operacao;','tipo_operacao;'])
        gravar.write('\n')
        next(ler)
        next(ler)


        for linha in ler:
            if  len(linha.strip()) > 0 and len(linha.strip("਍ഀ").strip()) > 0:
                linha = linha.rstrip()
                gravar.writelines(linha.replace('\t',';').strip()[:-2].rstrip()[1:].replace(".",'/',2).replace(".","",10))
                gravar.write('\n')
               #print(linha)



except AttributeError:
    print("Erro")

Ответы [ 2 ]

0 голосов
/ 27 марта 2020

Мне удалось получить доступ, добавлено / dbfs / , поэтому это выглядит так / dbfs / mnt / caminho / teste.txt

0 голосов
/ 27 марта 2020

Когда вы выполняете сценарий локально, вы используете локальные диски.

Когда вы запускаете его в Azure, если вы не запускаете его на виртуальной машине, у вас нет локальных дисков.

Вам необходимо настроить Azure File Share, а затем настроить свою программу для его использования. См .:

https://docs.microsoft.com/en-us/azure/storage/files/storage-how-to-use-files-windows

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...