Reputation: 135
I have an excel file with multiple sheets in it and I am reading each sheet as a separate csv file.
I am able to do it but in one of the csv files created, the data is starting from 21st line
till 20th line
there is some calculation(that i want to avoid).
Is there any method by which I can read such kind of data.
Thanks in advance.
Upvotes: 1
Views: 1310
Reputation: 141
If youre reading it as a pandas DataFrame, it's very simple to do:
df = pd.read_csv("name_of_csv_file.csv")
df = df[20:] # Returns line 21 onwards, because it is 0 indexed
Edit: If 20 was set to be dynamic, you can have a function return the value
n_skip = get_number_of_rows_to_skip()
df = df[n_skip:]
Upvotes: 1
Reputation: 313
There is an attribute inside read_csv function called skiprows. try to skip with that.
usersDf = pd.read_csv('users.csv', skiprows=21)
Upvotes: 1