Skip to content

Instantly share code, notes, and snippets.

@tiagocordeiro
Created April 19, 2018 18:04
Show Gist options
  • Save tiagocordeiro/5102029271bbb1ec644ea2f2506c7ba5 to your computer and use it in GitHub Desktop.
Save tiagocordeiro/5102029271bbb1ec644ea2f2506c7ba5 to your computer and use it in GitHub Desktop.
import xmltodict
import csv
with open('nfe_entrada_mock.xml') as fd:
nfe = xmltodict.parse(fd.read())
nfe_id = nfe['nfeProc']['NFe']['infNFe']['@Id'] # infNFe Id
itens = nfe['nfeProc']['NFe']['infNFe']['det']
print("NFe: ", nfe_id)
print("NCM | Equipamento")
for item in itens:
print(item['prod']['NCM'], "|", item['prod']['xProd'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment