Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iterator should return strings, not bytes (did you open the file in text mode?) #8

Open
TommasoBendinelli opened this issue Jul 15, 2020 · 3 comments

Comments

@TommasoBendinelli
Copy link

I am trying to run the experiment file, but I get the following error with the dataset that you have provided:

iterator should return strings, not bytes (did you open the file in text mode?) at line 217.

I am using python 3.7.6 and executing experiment.py with the following arguments:
python3 experiment.py data/settles.acl16.learning_traces.13m.csv.gz

@TommasoBendinelli
Copy link
Author

fixed by extracting the csv file and changing the reading from 'rb' to 'r'

@Jeriousman
Copy link

Hello. I have the same issue. When I tried your technique and executed 'python3 experiment.py settles.acl16.learning_traces.13m.csv' in command line, I get another error as below:

method = "hlr"
reading data...Traceback (most recent call last):
File "experiment.py", line 284, in
trainset, testset = read_data(args.input_file, args.method, args.b, args.l, args.max_lines)
File "experiment.py", line 244, in read_data
fv.append((intern('right'), math.sqrt(1+right)))
NameError: name 'intern' is not defined

How to fix it?

@BlueGreenMagick
Copy link

BlueGreenMagick commented Jan 14, 2021

@hojun0705 It looks like this code is written in Python 2, but you are trying to run it in Python3.

To run the code on Python 3, replace intern() to sys.intern(), for file open mode, 'rb' to 'rt', wb to w, and .iteritems() to .items().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants