Questions tagged [genfromtxt]

Numpy function to create arrays from tabular data.

References

287 questions
0
votes
1 answer

I'm using Python to load data points using genfromtxt command but getting error message "data.txt not found"

I've saved a .txt file of data points onto my desktop. I wrote my script in spyder as follows: from pylab import * data = genfromtxt('data.txt', skip_header = 5, skip_footer = 6) print data This returns an error code saying "data.txt not…
0
votes
1 answer

Is it possible to add a new field in a numpy.genfromtxt output?

I loaded a csv file and used the header to specify the names of each column. # Load the Data data = np.genfromtxt('dat_h.csv', delimiter=',', names=True) This is great, because I can access the columns by…
blaylockbk
  • 2,503
  • 2
  • 28
  • 43
0
votes
1 answer

Cannot use column slicing (correctly) in a matrix with data read from a CSV in Python

I am trying to read a CSV file (containing one column of strings and one of integers) into a matrix using genfromtxt and then use slicing to get only the column containing the string values and load it into an array for further processing. CSV File:…
Artemis
  • 123
  • 1
  • 8
0
votes
1 answer

Indexing a ndarray - 1 item is stored differently to >1

I'm using genfromtxt to import data from a txt file. This data is imported into an ndarray, as per genfromtxt Normally, this text file has many lines of data to inport, meaning that the ndarray is like this: array([ ('2016-04-17T00:08:42.273000Z',…
mjp
  • 1,618
  • 2
  • 22
  • 37
0
votes
1 answer

Auto convert strings and float columns using genfromtxt from numpy/python

I have several different data files that I need to import using genfromtxt. Each data file has different content. For example, file 1 may have all floats, file 2 may have all strings, and file 3 may have a combination of floats and strings etc. Also…
Emmanuel Sunil
  • 243
  • 4
  • 16
0
votes
1 answer

How to convert csv data into tuples with numpy genfromtxt?

I've been having trouble calling csv files in form of tuples with python. I'm using: csv_data = np.genfromtxt('csv-data.csv', dtype=int, delimiter=',', names=True) While the data looks like: (sorry I don't know how to display csv format) Trial1…
Vinci
  • 365
  • 1
  • 6
  • 16
0
votes
2 answers

Python Convert Datetime from csv for matplotlib

I am trying to plot from a csv file with column 1 as a datetime value, as below 27-08-2016 08:43 21.38329164 using this code: from matplotlib import pyplot as plt from matplotlib import style import numpy as np import datetime as dt from…
warrenfitzhenry
  • 2,209
  • 8
  • 34
  • 56
0
votes
2 answers

NumPy genfromxt TypeError: data type not understood error

I would like to read in this file…
Markus
  • 189
  • 1
  • 1
  • 10
0
votes
3 answers

Python Import Text Array with Numpy

I have a text file that looks like this: ... 5 [0, 1] [512, 479] 991 10 [1, 0] [706, 280] 986 15 [1, 0] [807, 175] 982 20 [1, 0] [895, 92] 987 ... Each column is tab separated, but there are arrays in some of the columns. Can I import…
user6748216
0
votes
1 answer

reading names with genfromtxt missing hyphen

I am trying to read the following file and I tried to use numpy to load data: #Frame HIE_21@O-PHE_32@N-H THR_20@O-PHE_32@N-H HIE_21@ND1-PHE_32@N-H 1 0 0 0 2 1 …
kris
  • 1
  • 1
0
votes
2 answers

How to create a new array at occurrence of specific string ? numpy

I have character delimited files which have different sets in the file File @Set 1 0,1,2,3 2,3,4,5 . . @Set 2 3,4,5,6 4,5,6,7 . . I want to make arrays with data from each set and I will also need from which set the data is…
Cheesebread
  • 91
  • 1
  • 10
0
votes
0 answers

Numpy Genfromtxt : deleted slashes

I am facing some trouble with the numpy genfromtxt fonction. It seems that the function is removing slashes from strings. Here is a simplified version of my code that shows the problem. Here, I create some dtype with a slash (/) in the string…
0
votes
1 answer

Spyder frozen when using dype karg

I am having a problem when using the Ipython interpreter of Spyder, basically when I run the following lines, import numpy as np my_data=np.genfromtxt(path_to_my_file,delimiter="\t",skip_header=1,dtype='str') The whole of Spyder gets frozen. I…
Numlet
  • 819
  • 1
  • 9
  • 21
0
votes
1 answer

Numpy's genfromtxt returns different structured data depending on dtype parameters

I have the following: from numpy import genfromtxt seg_data1 = genfromtxt('./datasets/segmentation.all', delimiter=',', dtype="|S5") seg_data2 = genfromtxt('./datasets/segmentation.all', delimiter=',', dtype=["|S5"] + ["float" for n in…
imyjimmy
  • 711
  • 2
  • 11
  • 18
0
votes
1 answer

plotting a Date from an csv. file in pylab

I'm trying to plot dates from a csv. file column against three other columns of numbers. I'm new to python and have so far managed to import the columns into python and have tried to read them has an array but i can't seem to append them with the…
Jacktt
  • 13
  • 3