A
A
Alexey Andrianov2014-03-31 18:34:02
Python
Alexey Andrianov, 2014-03-31 18:34:02

How to read CSV file in Python not from 1 line?

There is a CSV file.
I read it:

csv_data = csv.reader(file('temp.csv'))
for row in csv_data:
      print row

The task is to process this file by excluding 1 line from the file.

Answer the question

In order to leave comments, you need to log in

8 answer(s)
U
un1t, 2014-03-31
@andan

import csv
csv_iter =  csv.reader(file('temp.csv'))
next(csv_iter)
for row in csv_iter:
      print row

U
un1t, 2014-03-31
@un1t

I dare to assume that you want to skip the first line, because there are column names. In this case, I recommend using csv.DictReader

I
iroln, 2014-03-31
@iroln

from pandas import read_csv

out = read_csv(your_file, sep=';', skiprows=[0], header=None)

Access the received data through indexing:
The function can do much more . Pandas is a cool library for data analysis.

F
fabrykant, 2014-03-31
@fabrykant

It's a crutch, but it works

csv_data = csv.reader(file('temp.csv'))
data = []
for row in csv_data:
      data.append(row)
print data[1:]

D
D', 2015-08-12
@Doaxan

Do you want all the latest and complete control over the system?
Want to set up your desktop so that the girls give?
Your choice of Arch Linux:
- Latest packages
- Full control over the system
- Set up once, and work for years (until something breaks)

D
Disinterpreter, 2015-08-12
@Disinterpreter

Definitely ArchLinux

V
Vladimir, 2015-08-12
@azrail_dev

I currently have openSUSE 13.2 on a semi-working laptop
and the "stable kernel and new software versions" is Arch Linux

A
Andrey Abramov, 2015-08-20
@zmoe

For a beginner Linux Munt is best, for Gentoo gurus it's the middle of EVERYTHING else ;)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question