Questions tagged [genfromtxt]

Numpy function to create arrays from tabular data.

References

287 questions
1
vote
2 answers

Read file with missing data with loadtxt (numpy)

When I tried to read the data below with: loadtxt('RSTN') I got an error. Then I tried to complete this missing data using: genfromtxt('RSTN',delimiter=' ') But I got this error: Line #31112 (got 7 columns instead of 8) I'd like to fill the…
nandhos
  • 681
  • 2
  • 16
  • 31
1
vote
1 answer

Genfromtxt file name

I am trying to read a file name stored as a string in a data file. No problem there. If I pass it to genfromtxt I get error "IOError: Z:\Python\Rb input.txt not found." if I put the file name into genfromtxt explicitly it works this fails with…
1
vote
3 answers

too many values to unpack in genfromtxt

I have a tsv file containing vibration data (with commas in place of dots for some silly reason, hence the converter). I'd like to generate numpy arrays from two of these channels, but get a "ValueError: too many values to unpack (expected 2)" that…
sjp
  • 382
  • 4
  • 15
1
vote
2 answers

Python genfromtext multiple datatypes

I would like to read in a csv file using genfromtxt. I have six columns that are float, and one column that is a string. How do I set the datatype so that the float columns will be read in as floats and the string column will be read in as strings? …
user2483176
  • 317
  • 1
  • 10
  • 21
1
vote
1 answer

Genfromtxt throw exceptions "got 3 columns instead of 27" bu it is not so

I use: Data = np.genfromtxt(filename, delimiter='"\t"', dtype=None, autostrip=True, skip_header=1) And in proccess it gives me raise ValueError(errmsg) Line #33 (got 3 columns instead of 27) But it is not so. In file in that line I have all…
Il'ya Zhenin
  • 1,272
  • 2
  • 20
  • 31
1
vote
1 answer

numpy#genfromtxt raise an IOError while the txt file is empty

Then genfromtxt method of numpy load an ndarray from a text file. However, if the text file is empty, the method would raised an IOError while I expected an empty ndarray: IOError: End-of-file reached before encountering data. Is there any…
Eastsun
  • 18,526
  • 6
  • 57
  • 81
1
vote
1 answer

converters option in numpy genfromtxt not accepting -ve indexing of columns

I want to load only last few columns in a text file with some evaluation. I used numpy.genfromtxt with the argument converters={-1:func,-2:func} But it is not working. On the other hand if i give the forward indexing like…
indiajoe
  • 1,291
  • 3
  • 13
  • 26
1
vote
1 answer

reading file & joining two columns in numpy array

I have a text data like: 16/12/2006;17:24:00;1.000;17.000 with first column being date and second being time and rest just some floats. Right now I am reading the file like: np.genfromtxt(path, dtype=(np.datetime64, np.datetime64,…
mrig
  • 382
  • 1
  • 4
  • 21
1
vote
2 answers

forcing genfromtxt output to no-vector

Is there a way to force genfromtxt to output data with the shape : (xx, 1) in the case only one column of data is loaded? The usual shape is (xx, ). xx in my example could any integer. update: here is an example of code: import numpy as np a =…
user1850133
  • 2,833
  • 9
  • 29
  • 39
1
vote
1 answer

Import 36 columns in python for plotting, first column is date

I am trying to plot water-level hydrogaphs for multiple wells. The data are in a text file with the first column a date in the format 'yyyymmdd'. In this particular case, there are 35 other columns with float numbers. I have been trying to use…
1
vote
3 answers

Python: numpy.genfromtxt - Need column names that contain invalid characters

I am working on importing CSV files with numpy.genfromtxt. The data to be imported has a header of column names, and some of those column names contain characters that genfromtxt considers invalid. Specifically, some of the names contain "#" and "…
0
votes
2 answers

Combining columns in genfromtxt python

I have a data file containing 6 columns and I am going to read it using genfromtxt and store the data in such a way that the first and second column go to variables mCH, tb and the rest (columns 2 to 5) go to BR so that I can plot different BR…
0
votes
1 answer

How can I use genfromtxt in numpy to get 2D array instead of tupled or 1-D array

a=np.genfromtxt("winequality-red.csv", delimiter=":", dtype=None, encoding=None,\ skip_header=1, missing_values="??") ['7.40,0.70,0.00,1.90,0.08,11.00,34.00,1.00,3.51,0.56,9.40,5.00' …
0
votes
1 answer

genfromtxt file returns filling values as -1

I'm trying to use genfromtxt to extract a csv file that contains missing values such as 'na' and '-' I am required to look for the minimum value in the list of data, but the missing values got returned as -1. this is my code: data =…
Yue Min
  • 11
  • 3
0
votes
0 answers

What is the correct format and syntax for reading data with subarrays into numpy structured array?

I'm trying to use np.genfromtxt to read in a text file into a variety of data types, some of which are ideally sub arrays, however I can't seem to find the right code or input format for this, I've managed to get numpy to complain I both have too…
James B
  • 1
  • 1