Quick question regarding this screen.
Can anyone explain the variable
The logic is easy being that we added the second parameter,
header=True to utilize in the if/else conditional statement below it.
However, header is just a random variable, right? So, where is the actual calculation for checking the variable called
if header:, I get, but how does the program know what
def open_dataset(file_name='AppleStore.csv', header=True):
opened_file = open(file_name)
from csv import reader
read_file = reader(opened_file)
data = list(read_file)
apps_data = open_dataset
The program doesn’t know what
header is. The only thing the program knows is that if we declare
header=True, then it will return all the data excluding
data (the header row), and if we say
header=False, then it will return the entire dataset (since there is no header row). We, as the coder using the function, would want to know ahead of time if the dataset contains a header so that we know whether or not to make
header True or False appropriately in the function. (If we make a mistake and the data doesn’t really have a header row, we’re going to end up losing the first row of data when we don’t declare the header False!) I hope that makes sense!
This was confusing to me as well, I was operating under the impression that we need to create something that check swhether a header exists.
data is a string then there is a header and otherwise no.
Anyway, thanks for explaining.