Skip to content

A Python project that reads XML files from Electronic Invoices (NFe), extracts product information, and generates an organized Excel (.xlsx) table.

Notifications You must be signed in to change notification settings

nahtanpng/xml-to-excel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“„ XML NFe to Excel

A Python project that reads XML files from Electronic Invoices (NFe), extracts product information, and generates an organized Excel (.xlsx) table.

πŸ“Š Features

  • πŸ“‚ Reads all .xml files from a directory.
  • πŸ“„ Extracts the following information from each NFe:
    • Emission Date
    • Product
    • Quantity
    • Unit Value
    • Total Value
  • πŸ“Š Creates a consolidated Excel file with a separate sheet for each NFe.
  • βœ… Displays the Emission Date only in the first row of each sheet.

πŸ“‹ Requirements

  • Python 3.10 or higher
  • Required libraries:
pip install pandas openpyxl

πŸ“ Project Structure

xml_to_excel/
β”œβ”€β”€ main.py          # Main script
β”œβ”€β”€ requirements.txt # Dependencies
└── README.md        # Project documentation

πŸš€ How to Run

  1. Clone the repository
git clone https://github.com/your-username/xml-to-excel.git
cd xml-to-excel
  1. Install dependencies
pip install -r requirements.txt
  1. Run the script
python main.py <your/xml/files/directory>
  1. Output:
  • The output.xlsx file will be generated in the specified directory, with a sheet for each processed XML file.

πŸ“Š Example Output

Date Product Quantity Unit Value Total Value
2024-02-07T14:30:00 Product A 2 50.00 100.00
Product B 1 30.00 30.00
Product C 5 10.00 50.00

πŸ› οΈ Customization

If you need to adjust the extracted fields, edit the find calls inside the loop that processes products in the XML.

πŸ“Œ Notes

  • Ensure the XML files follow the NFe standard and contain the correct namespaces.
  • Each sheet name in the Excel file is based on the XML file name (limited to 31 characters).

πŸ“„ License

This project is licensed under the MIT License.

About

A Python project that reads XML files from Electronic Invoices (NFe), extracts product information, and generates an organized Excel (.xlsx) table.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages