0

This is the current code that i have:

with open('some_file.csv', mode='r') as fp:
    reader = csv.reader(fp)
    for row in reader:
        print(row[0])

And I have a csv file that looks something like:

email@email.com,Name
email2@email.com, Name2
and so on...

But when I run this code, it automatically skips the 1st row because it thinks it is a header. I do not want to skip the 1st row and print everything out. How to do that? Thanks.

1 Answers1

0

You can use pandas and set header equal to None :

here is an example :

import pandas as pd

df = pd.read_csv('some_file.csv', header=None)
Fou
  • 161
  • 1
  • 9
  • good googling https://stackoverflow.com/questions/43056263/how-to-read-csv-without-header-in-pandas but he wants to use csv.reader – E.Serra Oct 12 '18 at 15:20
  • Ok, I tried with both python2 & 3, and csv.reader and it reads also the first line of my csv files – Fou Oct 12 '18 at 15:27
  • 1
    yeah I don't understand why he wants to use csv reader, he can just do for l in file: a.split(sep) – E.Serra Oct 12 '18 at 15:28
  • 1
    @E.Serra Perhaps OP has quoted fields or escaped quotes. `csv` handles that. `split` doesn't. – Mark Tolonen Oct 12 '18 at 15:41