Numpy function to create arrays from tabular data.
Questions tagged [genfromtxt]
287 questions
3
votes
1 answer
How to display a NumPy array of strings without quotes and with comma as a delimiter?
I am trying to generate an array out of a file with numpy.genfromtxt.
File is like:
16.37.235.200|59009|514|16.37.235.153|
17.37.235.200|59009|514|18.37.235.153|
And I get an array like:
['16.37.235.200' '17.37.235.200']
But I want the array to…

QWERASDFYXCV
- 245
- 1
- 6
- 15
3
votes
2 answers
np.genfromtxt multiple delimiters?
My file looks like this:
1497484825;34425;-4,28,-14;-4,28,-14;-4,28,-14;-4,28,-14;-4,28,-14;-4,28,-14
1497484837;34476;-4,28,-14;-4,28,-14;-4,28,-14;-4,28,-14;-4,28,-14;-4,28,-14
I want to import it into numpy array using np.genfromtxt. The…

mihagazvoda
- 1,057
- 13
- 23
3
votes
1 answer
Numpy genfromtxt iterate over columns
I am using NumPy's genfromtext to get columns from a CSV file.
Each column needs to be split and assigned to a separate SQLAlchemy SystemRecord combined with some other columns and attributes and added to the DB.
Whats the best practice to iterate…

codervince
- 316
- 4
- 15
3
votes
3 answers
load a certain number of rows from csv with numpy
I have a very long file and I only need parts, a slice, of it.
There is new data coming in so the file will potentially get longer.
To load the data from the CSV I use numpy.genfromtxt
np.genfromtxt(filename, usecols={col}, delimiter=",",…

BlueScr33n
- 55
- 1
- 7
3
votes
1 answer
How to import same column name data with np.genfromtxt?
I have data in the file data.dat of the form:
column_1 col col col col col
1 2 3 1 2 3
4 3 2 3 2 4
1 4 3 1 4 3
5 6 4 5 6 4
And I am trying to import using np.genfromtxt, so that all data with column name…

Tom Kurushingal
- 6,086
- 20
- 54
- 86
3
votes
1 answer
Python genfromtxt file path
I have an extremely basic problem with the numpy.genfromtxt function. I'm using the Enthought Canopy package: where shall I save the file.txt I want to use, or how shall I tell Python where to look for it? When using IDLE I simply save the file in a…

DavideL
- 294
- 1
- 3
- 15
3
votes
3 answers
Fastest way to read every n-th row with numpy's genfromtxt
I read my data with numpy's genfromtxt:
import numpy as np
measurement = np.genfromtxt('measurementProfile2.txt', delimiter=None, dtype=None, skip_header=4, skip_footer=2, usecols=(3,0,2))
rows, columns = np.shape(measurement)
x=np.zeros((rows, 1),…

user69453
- 1,279
- 1
- 17
- 43
3
votes
1 answer
How to extract data from .csv file and create a plot?
I have a .csv file with 24columns x 514rows of data. Each of these column represent different parameters and I wish to study the trends between different parameters.
I am using genfromtxt to import the data as a numpy array such that I can plot the…

Kristine
- 43
- 1
- 5
3
votes
1 answer
How to control genfromtxt to read rows specified?
genfromtxt can skip header and footer lines and speicfy which columns to use.
But how can I control how many lines to read?
Sometimes a txt file might contain several blocks with different shape.
For…

Syrtis Major
- 3,791
- 1
- 30
- 40
3
votes
2 answers
numpy genfromtxt converters unknown number of columns
I have several data numeric files in which the decimal separator is a comma. So I use a lambda function to do a conversion:
import numpy as np
def decimal_converter(num_cols):
conv = dict((col, lambda valstr: \
…

user1850133
- 2,833
- 9
- 29
- 39
3
votes
1 answer
numpy.genfromtxt: delimiter=',' fails to split string
I don't understand why numpy.genfromtxt doesn't split the following string correctly using delimiter="," while it works for most of the other strings in my chunk.
chunk[12968]
Out[143]:…

user17375
- 529
- 4
- 14
3
votes
1 answer
Using converter function in genfromtxt fails
When I try to read a space separated file using genfromtxt and using a converter function to convert numbers with a comma as decimal separator, I get a type error. It seems there is something wrong with my converter function. However, when I use it…

Puggie
- 3,867
- 2
- 35
- 39
3
votes
1 answer
numpy genfromtxt columns
I am having what seems like a stupidly simple problem with numpy genfromtxt. This is a (very) simplified version of my code:
import numpy as np
in_file_1 = raw_input ('enter name of template file to be scaled:\n')
spec_1 = np.genfromtxt(in_file_1,…

Darryl Sergison
- 31
- 1
- 2
2
votes
0 answers
run genfromdata get an OSError
When I tried this code in local sublime editor
data = np.genfromtxt('https://raw.githubusercontent.com/kaustubholpadkar/Linear_Regression-Gradient_Descent-Octave/master/data.csv', delimiter=',')
I got an error like this
OSError:…

Susan
- 13
- 2
2
votes
1 answer
Importing data using Numpy genfromtext and formatting column with datetime
I have a long text file that I am importing with numpy genfromtext:
00:00:01 W 348 18.2 55.9 049 1008.8 0.000
00:00:02 W 012 12.5 55.9 049 1008.8 0.000
00:00:03 W 012 12.5 55.9 049 1008.8 0.000
00:00:04 W 357 18.2 55.9 049 1008.8 0.000
00:00:05 W…

Jonathon
- 251
- 1
- 7
- 20