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

IndexError: list index out of range #2

Open
NoahCardoza opened this issue Mar 30, 2021 · 9 comments
Open

IndexError: list index out of range #2

NoahCardoza opened this issue Mar 30, 2021 · 9 comments

Comments

@NoahCardoza
Copy link

NoahCardoza commented Mar 30, 2021

Traceback (most recent call last):
  File "/Users/vulcan/projects/vanished.io/backend/data/data-gen.py", line 31, in <module>
    print(randominfo.get_email(randominfo.Person()))
  File "/Users/vulcan/.pyenv/versions/3.9.0/lib/python3.9/site-packages/randominfo/__init__.py", line 297, in __init__
    self.address = get_address()
  File "/Users/vulcan/.pyenv/versions/3.9.0/lib/python3.9/site-packages/randominfo/__init__.py", line 267, in get_address
    if addr[i] != '':
IndexError: list index out of range

Thought I'd give this project a try but no luck.. I'm on Mac running Python 3.9.

@AlfonsoCuesta
Copy link

Same... Mac running Python 3.8.
As far as I have seen, the bug is in the get_address () function, it extracts the addresses of a csv with 10 columns, although from the code it tries to access up to 12.

@Adwaith-Rajesh
Copy link

Same issue here, running windows python 3.9

@Adwaith-Rajesh
Copy link

Same... Mac running Python 3.8.
As far as I have seen, the bug is in the get_address () function, it extracts the addresses of a csv with 10 columns, although from the code it tries to access up to 12.

I tried adding a if statement that prevents the "error prone if statement" from checking if 'i' is below a certain number but another list index out of range error occurs some where else.

@AlfonsoCuesta
Copy link

I think the problem is in the data.csv, the function is taken in order each value, but in the csv the values are in the wrong position. There must be missing fields in the csv or something like this, because if you change the range for I you will get something but in wrong positions and null elements.

@puroong
Copy link

puroong commented Apr 16, 2021

def get_address():
	full_addr = []
	addrParam = ['street', 'landmark', 'area', 'city', 'state', 'country', 'pincode']
	for i in range(5,12):
		addrFile = csv.reader(open(full_path('data.csv'), 'r'))
		allAddrs = []
		for addr in addrFile:
			if addr[i] != '':
				allAddrs.append(addr[i])
		full_addr.append(choice(allAddrs))
	full_addr = dict(zip(addrParam, full_addr))
	return full_addr

iTcEOYxzmQ4m

it seems range is set to 5~12 while csv has only 10 columns

@alex-pancho
Copy link

alex-pancho commented May 21, 2022

def get_address():
	full_addr = []
	addrParam = ['street', 'landmark', 'area', 'city', 'state', 'country', 'pincode']
	for i in range(5,12):
		addrFile = csv.reader(open(full_path('data.csv'), 'r'))
		allAddrs = []
		for addr in addrFile:
			if addr != '':
				allAddrs.append(addr)
		full_addr.append(choice(allAddrs))
	full_addr = dict(zip(addrParam, full_addr))
	return full_addr

@alex-pancho
Copy link

fix a lot of error in fork: https://github.com/alex-pancho/randominfo

@lucasschn
Copy link

@alex-pancho Thanks for fixing it! Is your fork available on pip? If not, why not opening a PR here?

@lucasschn
Copy link

I tried with pip install rndinfo, but I couldn't find any distribution there

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

No branches or pull requests

6 participants