# Python3 to Pyxl

**URL:** <https://forum.core-electronics.com.au/t/python3-to-pyxl/9049>\
**Category:** Uncategorized\
**Created:** [22 December 2020 05:28 UTC](https://forum.core-electronics.com.au/t/python3-to-pyxl/9049 "2020-12-22T05:28:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason136169](https://avatars.discourse-cdn.com/v4/letter/j/f17d59/32.png) [@Jason136169](https://forum.core-electronics.com.au/u/Jason136169)\
**Post date:** [22 December 2020 05:28 UTC](https://forum.core-electronics.com.au/t/python3-to-pyxl/9049/1 "2020-12-22T05:28:01Z")

</div>

Hello,

I have been following tutorial:

[A Guide to Excel Spreadsheets in Python With openpyxl – Real Python]  
[https://realpython.com/openpyxl-excel-spreadsheets-python/#practical-use-cases](https://realpython.com/openpyxl-excel-spreadsheets-python/#practical-use-cases))

But when I open the Python3 IDLE and enter:

```auto
from openpyxl import load_workbook
workbook = load_workbook(filename="sample.xlsx")
workbook.sheetnames

sheet = workbook.active
sheet

sheet.title

```

I get this:

```auto
Python 3.9.1 (v3.9.1:1e5d33e9b9, Dec 7 2020, 12:44:01) 
[Clang 12.0.0 (clang-1200.0.32.27)] on darwin
Type "help", "copyright", "credits" or "license()" for more information.
>>> from openpyxl import load_workbook
workbook = load_workbook(filename="sample.xlsx")
workbook.sheetnames

sheet = workbook.active
sheet

sheet.title

SyntaxError: multiple statements found while compiling a single statement
>>> 

```

Can anyone help please

Jason

---

<div class="post-metadata">

**Author:** ![Jason136169](https://avatars.discourse-cdn.com/v4/letter/j/f17d59/32.png) [@Jason136169](https://forum.core-electronics.com.au/u/Jason136169)\
**Post date:** [22 December 2020 19:16 UTC](https://forum.core-electronics.com.au/t/python3-to-pyxl/9049/2 "2020-12-22T19:16:21Z")

</div>

I have tried typing in script manually, still not working:

```auto
>>> from openpyxl import load_workbook
>>> workbook = load_workbook(filename=‘sample.xlsx’)
SyntaxError: invalid character '‘' (U+2018)

```

or:

```auto
>>> from openpyxl import load_workbook
>>> workbook = load_workbook(filename = sample.xlsx)
Traceback (most recent call last):
  File "<pyshell#6>", line 1, in <module>
    workbook = load_workbook(filename = sample.xlsx)
NameError: name 'sample' is not defined

```

The first error I just don’t understand, but the second refers to name error. I have tried different paths to the file with no success.

Still need some help please  
Jason

---

<div class="post-metadata">

**Author:** ![Jason136169](https://avatars.discourse-cdn.com/v4/letter/j/f17d59/32.png) [@Jason136169](https://forum.core-electronics.com.au/u/Jason136169)\
**Post date:** [22 December 2020 22:55 UTC](https://forum.core-electronics.com.au/t/python3-to-pyxl/9049/3 "2020-12-22T22:55:23Z")

</div>

Success,

I found the path to file by right click on the file then press and hold option button. This changes copy to copy" “as pathname, click on copy” "as pathname and you have it to paste wherever you like. I am using a MacBook Pro with Big Sur.

Working things out slowly!  
Jason

---

<div class="post-metadata">

**Author:** ![Robin57159](https://avatars.discourse-cdn.com/v4/letter/r/cc9497/32.png) [@Robin57159](https://forum.core-electronics.com.au/u/Robin57159)\
**Post date:** [22 December 2020 23:58 UTC](https://forum.core-electronics.com.au/t/python3-to-pyxl/9049/4 "2020-12-22T23:58:24Z")

</div>

When putting quotes around the filename, you need to use either the single quote ’ at the start and end, or the double quote ". The same quote opens and closes the string. You were using the opening (backward?) quote at the start of the string, and python doesn’t like that. So use ‘file’ not `file’, or “file”.

Hope this helps.
