Reputation: 139
I am getting an error stating that global name 'data' not defined.
Upvotes: 0
Views: 102
Reputation: 11
You need to correct this line :
with open(data, 'r') as f:
To :
with open(self.data, 'r') as f:
Upvotes: 1
Reputation: 6637
In ParseCSV
class constructor you set self.data
by data
parameter, this means that you can access data
by self
in other methods of the class, change line 6 to below form:
...
with open(self.data, 'r') as f:
...
Upvotes: 0
Reputation: 90889
You need to reference data
variable using the self
variable.
Like -
with open(self.data,'r') as f:
Upvotes: 3
Reputation: 1238
You want to do
def read_data(self):
with open(self.data, 'r') as f
...
Upvotes: 5