Python Online Compiler & Playground
HTML/CSS/JavaScript
HTML
CSS
Javascript
C++
C
PHP
Java
Python
Swift
C#
Ruby
Node.JS
Kotlin
jQuery
Go
R
TypeScript
Start Python Course
Register
pandas read specific csv lines
+2
Author: Rora
Dark
Public
Save
PY
py
1
2
3
4
5
6
7
import
pandas
as
pd
with
open
(
'file.csv'
,
'w+'
)
as
f
:
f.writelines
(
'7, 8, 8 \n 7, 6, 5 \n 6, 5, 4'
)
dataframe = pd.read_csv
(
'file.csv'
,
nrows =
2
,
header =
None
)
print
(
dataframe
)
Enter to Rename, Shift+Enter to Preview
OUTPUT