.readline() not working
I tried opening and reading from a csv file with .readline() but it didn’t work.
I searched it up on the internet, installed stash but stash couldn’t pip install it either.
I couldn’t find any solution to install it manually.
Any help is appreciated.
Did you mean .readlines()?
Maybe show us your script
I tried both .readline() and .readlines()
My script isn’t anything fancy
Neither is working
with open('menu.csv', mode='rt') as fil: lines = fil.readlines()
I tried but it still gives me a UnicodeDecodeError on the line with .readlines()
Edit: Here is the Error:
Traceback (most recent call last):
File "/private/var/mobile/Containers/Shared/AppGroup/8D3D7AE1-1CB4-436D-B202-B8EBCDA65D5F/Pythonista3/Documents/mcdonalds.py", line 6, in <module>
lines = fil.readlines()
File "/var/containers/Bundle/Application/25DCAAA8-B420-4833-8B49-78EB3B0BD979/Pythonista3.app/Frameworks/Py3Kit.framework/pylib/encodings/ascii.py", line 27, in decode
return codecs.ascii_decode(input, self.errors)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3461: ordinal not in range(128)
@810D ok, errors on special characters like emoji, try
with open('menu.csv', mode='rt', encoding='utf-8', errors="surrogateescape") as fil:
Thank you so much, it is working.
@810D 👍 and welcome in this marvelous forum of a marvelous app