首页 > 解决方案 > 在 python 中找不到 azure 中的目录或文件

问题描述

我在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")

标签: pythonazurepysparkazure-active-directory

解决方案


我设法访问,添加/dbfs/,所以它看起来像这样/dbfs/mnt/caminho/teste.txt


推荐阅读