Questions tagged [genfromtxt]

Numpy function to create arrays from tabular data.

References

287 questions
2
votes
1 answer

python genfromtxt problems

I am new to Python...here is my problem. For an optimizing subroutine I am testing in Python, I need to parse a csv file with numbers. The format of the csv file is thus: Support load summary for anchor at node 5, Load combination,FX (N),FY…
2
votes
1 answer

Merging numpy ndarray from CSVs

I have the following code: from numpy import genfromtxt nysedatafile = os.getcwd() + '/nyse.txt'; nysedata = genfromtxt(nysedatafile, delimiter='\t', names=True, dtype=None); nasdaqdatafile = os.getcwd() + '/nasdaq.txt'; nasdaqdata =…
BlueTrin
  • 9,610
  • 12
  • 49
  • 78
2
votes
1 answer

using genfromtxt to split data

With Python, I am using genfromtxt (from numpy) to read in a text file into an array: y = np.genfromtxt("1400list.txt", dtype=[('mystring','S20'),('myfloat','float')]) Which works okay, except it doesn't seem to read my 2 columns into a 2D array. I…
user1551817
  • 6,693
  • 22
  • 72
  • 109
1
vote
1 answer

Numpy genfromtxt and PyQt file handling (bug ?)

I'm trying to create a very simple stand-alone app that converts CATIA .dat files into csv for ProCast. I have a Qtwidget File dialog to get the .dat file : app = QtGui.QApplication(sys.argv) widget = QtGui.QWidget() widget.show() DATFILE =…
Félix Cantournet
  • 1,941
  • 13
  • 17
1
vote
1 answer

Reading csv with numpy has extra row of 1's

I am using np.genfromtxt to read a csv file, and trying to use the converters argument to preprocess each…
efthimio
  • 592
  • 5
  • 19
1
vote
2 answers

How to use genfromtxt with with brackets in format?

I have a csv file with the following values: # number,array1,array2 0,[1,2,3,4,5],[6,7,8,9,10] Now I would like to load these two arrays, but when i run: new_array = np.genfromtxt(fname='file_name.csv', skip_header=1, …
1
vote
1 answer

Use np.genfromtxt to read data of different dtypes in csv file

I am trying to read a csv file of that looks like: label,value first,1.234e-01 second,5.678e-02 three,9.876e-03 ... etc Where the first column contains strings and the second column contains floats. From the online documentation of np.genfromtxt I…
1
vote
2 answers

Add a space in 2D array when writing a text file

I am trying to store a 2D vector into a .DAT file and I would like to add a space at the start of every row. An example of a desired output looks like this: 0.0000000E+00 0.0000000E+00 2.0020020E-03 0.0000000E+00 4.0040040E-03 0.0000000E+00 …
Tan Phan
  • 99
  • 5
1
vote
1 answer

Import csv using genfromtxt() and converters

import numpy as np import csv filename = "a.csv" def convert(s): s = s.strip().replace(',', '.') return str(s) salary_data = np.genfromtxt(filename, delimiter= ',', …
LLynn
  • 19
  • 4
1
vote
1 answer

np.genfromtxt returns string with 'b'

I am learning about different functions of NUmpy, And I have a dummy dataset here named as 100-Sales-Records. Now I want to read it using np.genfromtxt. My code to read it is df3 = np.genfromtxt('100 Sales Records.csv', delimiter=',',names=True,…
Ahmad Anis
  • 2,322
  • 4
  • 25
  • 54
1
vote
1 answer

Running over files in a directory creates an extra nan array

I'm using the following for loop that runs over a directory that contains a few files with a list of numbers (nodes). for filename in os.listdir(nodes_path): nodes_arr = np.genfromtxt(os.path.join(nodes_path, filename), delimiter=',') print…
1
vote
2 answers

Why do I get NaN when using .mean()

This is a part of a GIT open course that I am taking in my free time to learn python. The exercise deals only with numpy. So, below is creating a filepath and importing the data. I added skip_header because column names are strings and I get Nan.…
mkw
  • 123
  • 2
  • 10
1
vote
2 answers

numpy genfromtxt reading first value of csv as missing?

I am trying to use numpy's genfromtxt to read csv's of bond lengths and energies into arrays (to use to generate a potential energy surface and reaction path, so I'll be using scipy.interpolate--hence the need for every value...). The problem is…
Clare Birch
  • 13
  • 1
  • 4
1
vote
0 answers

Open a .mtx file - Detect line change

I am trying to open a .mtx file and print the data out, mainly to see how the data is loaded. I want to use the data itself as soon I can load it all, but currently, it loads the first line only, and says it fails after that line. Debug Assertion…
user11119570
1
vote
1 answer

numpy.genfromtxt return NaN values

I am trying to plot second column of a csv file but second column returning the nan values. If I set the dtype= None or dtype= str will return the string values which at the end cause plotting in the wrong way in Y axis. any comment would…
AI_NA
  • 336
  • 2
  • 5
  • 20