Get header in genfromtxt when using skip_header
up vote
-1
down vote
favorite
I have data I want to plot and analyse, looking like:
0101
1 3
2 4
3 6
I use skip_header in genfromtxt to load the file 2 column data, however I also need the header for reference.
Is there a way to get the header back?
python numpy genfromtxt
add a comment |
up vote
-1
down vote
favorite
I have data I want to plot and analyse, looking like:
0101
1 3
2 4
3 6
I use skip_header in genfromtxt to load the file 2 column data, however I also need the header for reference.
Is there a way to get the header back?
python numpy genfromtxt
Use a regular Python file read to get that line,
– hpaulj
11 hours ago
Forgenfrontxt
this isn't a valid column header. So are right to skip it. And there's no provision for saving or recording skipped lines. Why should there be?
– hpaulj
5 hours ago
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I have data I want to plot and analyse, looking like:
0101
1 3
2 4
3 6
I use skip_header in genfromtxt to load the file 2 column data, however I also need the header for reference.
Is there a way to get the header back?
python numpy genfromtxt
I have data I want to plot and analyse, looking like:
0101
1 3
2 4
3 6
I use skip_header in genfromtxt to load the file 2 column data, however I also need the header for reference.
Is there a way to get the header back?
python numpy genfromtxt
python numpy genfromtxt
edited 11 hours ago
hpaulj
107k673137
107k673137
asked 12 hours ago
StarStrides
5119
5119
Use a regular Python file read to get that line,
– hpaulj
11 hours ago
Forgenfrontxt
this isn't a valid column header. So are right to skip it. And there's no provision for saving or recording skipped lines. Why should there be?
– hpaulj
5 hours ago
add a comment |
Use a regular Python file read to get that line,
– hpaulj
11 hours ago
Forgenfrontxt
this isn't a valid column header. So are right to skip it. And there's no provision for saving or recording skipped lines. Why should there be?
– hpaulj
5 hours ago
Use a regular Python file read to get that line,
– hpaulj
11 hours ago
Use a regular Python file read to get that line,
– hpaulj
11 hours ago
For
genfrontxt
this isn't a valid column header. So are right to skip it. And there's no provision for saving or recording skipped lines. Why should there be?– hpaulj
5 hours ago
For
genfrontxt
this isn't a valid column header. So are right to skip it. And there's no provision for saving or recording skipped lines. Why should there be?– hpaulj
5 hours ago
add a comment |
2 Answers
2
active
oldest
votes
up vote
0
down vote
I am not sure that this is implemented in numpy.genfromtxt(). You may have to call the function twice, once for the header, and a second time for the data. Or you may want to have a look at the functions offered by pandas, such as read_table.
New contributor
add a comment |
up vote
0
down vote
You can try with pd.read_csv:
data = pd.read_csv(filename, sep=" ")
So that the first line is read as header
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
I am not sure that this is implemented in numpy.genfromtxt(). You may have to call the function twice, once for the header, and a second time for the data. Or you may want to have a look at the functions offered by pandas, such as read_table.
New contributor
add a comment |
up vote
0
down vote
I am not sure that this is implemented in numpy.genfromtxt(). You may have to call the function twice, once for the header, and a second time for the data. Or you may want to have a look at the functions offered by pandas, such as read_table.
New contributor
add a comment |
up vote
0
down vote
up vote
0
down vote
I am not sure that this is implemented in numpy.genfromtxt(). You may have to call the function twice, once for the header, and a second time for the data. Or you may want to have a look at the functions offered by pandas, such as read_table.
New contributor
I am not sure that this is implemented in numpy.genfromtxt(). You may have to call the function twice, once for the header, and a second time for the data. Or you may want to have a look at the functions offered by pandas, such as read_table.
New contributor
New contributor
answered 12 hours ago
Patol75
4636
4636
New contributor
New contributor
add a comment |
add a comment |
up vote
0
down vote
You can try with pd.read_csv:
data = pd.read_csv(filename, sep=" ")
So that the first line is read as header
add a comment |
up vote
0
down vote
You can try with pd.read_csv:
data = pd.read_csv(filename, sep=" ")
So that the first line is read as header
add a comment |
up vote
0
down vote
up vote
0
down vote
You can try with pd.read_csv:
data = pd.read_csv(filename, sep=" ")
So that the first line is read as header
You can try with pd.read_csv:
data = pd.read_csv(filename, sep=" ")
So that the first line is read as header
edited 11 hours ago
answered 12 hours ago
Joe
5,36221127
5,36221127
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53371876%2fget-header-in-genfromtxt-when-using-skip-header%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Use a regular Python file read to get that line,
– hpaulj
11 hours ago
For
genfrontxt
this isn't a valid column header. So are right to skip it. And there's no provision for saving or recording skipped lines. Why should there be?– hpaulj
5 hours ago