Questions tagged [genfromtxt]

Numpy function to create arrays from tabular data.

References

287 questions
1
vote
1 answer

Read ints from .txt file into numpy array

I'm tring to read 4 ints from simple .txt array as described in this question genfromtxt : read ints from space separated .txt file but I want it as 2D numpy array. def read_data(): data = np.genfromtxt('Skin_NonSkin.txt', dtype=(int, int, int,…
mrgloom
  • 20,061
  • 36
  • 171
  • 301
1
vote
1 answer

How to split a mixed dtype 1D numpy array?

Maybe this has been answered before but I'm having a hard time searching the question. Assume I have the following data in a file: date, id, int1, int2, int3 02/03/2015, 2, 23, 65, 99 10/06/2016, 4, 84, 12, 35 10/01/2017, 6, 53, 6, 78 I can quickly…
1
vote
1 answer

Matplotlib/Genfromtxt: Multiple plots against time, skipping missing data points, from .csv

I've been able to import and plot multiple columns of data against the same x axis (time) with legends, from csv files using genfromtxt as shown in this link: Matplotlib: Import and plot multiple time series with legends direct from .csv The above…
DaveW
  • 185
  • 1
  • 8
1
vote
1 answer

deletechars parameter in genfromtxt not working as expected

I am working with some csv that have single quotes surrounding the values of the first column. I need to remove them in order to do further comparisons against other stuff. So I really need to perform this replacement efficiently. I am using…
divmermarlav
  • 183
  • 1
  • 2
  • 13
1
vote
1 answer

Python 3.2 - Numpy 1.9 genfromtxt

I am trying to read in a file that has multiple data formats in a .csv format. I am using Python3.2 and Numpy 1.9. I am using the numpy genfromtxt function to read in the data. I was hoping i could convert the data as I read to store it…
1
vote
1 answer

Skip a specified number of columns with numpy.genfromtxt() python 3.4 error

import os import numpy as np import matplotlib.pyplot as plt # Open a file path = "input/" filelist = list(filter(lambda s: s.endswith(".asc"), os.listdir(path))) firstImage = np.genfromtxt (" ".join(ln.split()[1:]) for ln in…
Klasik
  • 872
  • 1
  • 9
  • 29
1
vote
3 answers

Why doesn't np.genfromtxt() remove header while importing in Python?

I have data of the form: #--------------------- # Data #--------------------- p q r y 1 y 2 y 3 y 4 2 8 14 748 748 748 790 2 9 22 262 245 252 328 1 5 19 512 514 511 569 2 7 19 748 748 748 805 3 11 13 160 168 108 164 2 …
Tom Kurushingal
  • 6,086
  • 20
  • 54
  • 86
1
vote
3 answers

Remove chosen lines in an np.array

I have a selection of values coming from an experiment and I want to drop some of the lines with respect to other lines. Meaning: I measure a field, a polarization and an error of the polarization. Now the machine doing this measurement sometimes…
xtlc
  • 1,070
  • 1
  • 15
  • 41
1
vote
3 answers

genfromtxt error - Got n columns instead of m

I am trying to import data using numpy's genfromtxt with header names and non-homogeneous data types. Every time I run the program I get the error: Traceback (most recent call last): raise ValueError(errmsg) ValueError: Some errors were detected…
Tom Kurushingal
  • 6,086
  • 20
  • 54
  • 86
1
vote
1 answer

numpy.genfromtxt Error with convert function

I've data set which contains dates,data as shown below. the data is in mixed format and what I want to is to read date in datetime format and data in float and to store in a numpy matrix. CST,Max Tempe atu eC,Mean Tempe atu eC,Min Tempe atu eC,Dew…
pkv
  • 107
  • 1
  • 11
1
vote
1 answer

Plotting multiple columns with Python from CSV file

I have a csv file with 25 columns and 90 rows. The first column is in date format such that it appears as 01-10-2014 for example. The rest of the columns contain numbers that correspond to those dates. The first row is the name for each column. My…
Marmo
  • 11
  • 1
  • 3
1
vote
2 answers

Reading dates and data from a file (Python)

I'd wanna to read time strings and data from a file but when I used loadtxt i cant read string and numbers at the same time because strings are not float. So i tried using genfromtxt and use delimiter=[]+[]+[] acording the columns that I have, but…
nandhos
  • 681
  • 2
  • 16
  • 31
1
vote
1 answer

numpy.genfromtxt skips/ignores last line in long tsv file

I have a tsv-file from QuickDAQ with three columns of 200 000 values that I want to import into numpy. Problem is genfromtxt seems to miss the last line. The line is nothing out of the ordinary as far as I can see: ... 0,00232172012329102 …
sjp
  • 382
  • 4
  • 15
1
vote
1 answer

How to force genfromtxt read csv as record array?

I'm trying to read CSV with the following line: raw_data = genfromtxt(datafile,delimiter='\t',dtype=None) OK, this function reads this file into Record Array when it meets string data in the datafile. as far as I understand, when dtype is None,…
drsealks
  • 2,282
  • 1
  • 17
  • 34
1
vote
1 answer

using numpy to import multiple text files

I've been importing multiple txt files and using them to create plots. The code is the same as before but it isn't seeming to work this time. I've taken it back to basics and I have no idea what's going wrong. import numpy close('all') data…