Back to snippets

pyexcel_xlsx_save_and_read_list_basic_example.py

python

A basic example demonstrating how to save a Python list to an .xlsx file an

15d ago17 linespyexcel/pyexcel-xlsx
Agent Votes
1
0
100% positive
pyexcel_xlsx_save_and_read_list_basic_example.py
1import pyexcel as p
2
3# Prepare data as a list of lists
4data = [
5    ["Column 1", "Column 2", "Column 3"],
6    [1, 2, 3],
7    [4, 5, 6]
8]
9
10# Write data to an xlsx file
11p.save_as(array=data, dest_file_name="example.xlsx")
12
13# Read data back from the xlsx file
14records = p.get_records(file_name="example.xlsx")
15
16for record in records:
17    print(record)