Questions tagged [genfromtxt]

Numpy function to create arrays from tabular data.

References

287 questions
0
votes
1 answer

Special Charecter in Header line during text import

I'm trying to write a python script to import a data file generated by data aquistion software (EC-lab). I would like to keep the column headers as they are in the file and not manually define them since they are not uniform across all files…
0
votes
1 answer

Numpy genfromtxt doesn't seem to work when names=True for Python 3

I am using the Google Colab enviroment. The file I am using can be found here. It is a csv file https://drive.google.com/open?id=1v7Mm6S8BVtou1iIfobY43LRF8MgGdjfU Warning: it has several million rows. This code runs within a minute in Google Colab…
SantoshGupta7
  • 5,607
  • 14
  • 58
  • 116
0
votes
3 answers

Skip all rows containing strings and keep only rows with floats

I have a log file from a mathematical simulation. I tried to parse it in Python, but I am not quite satisfied with the result. Is there any "elegant" way to loop each line and sort it in order to keep only lines with physical values and ditch the…
zentafun
  • 13
  • 2
0
votes
1 answer

How to read a file with fortran formatted numbers into python?

I have a fortran formatted txt file with numbers like this 0.755473D-08. if I use np.genfromtxt(data,dtype=None), it shows b'0.755473D-08'. How can I can I get rid of b?
kinder chen
  • 1,371
  • 5
  • 15
  • 25
0
votes
1 answer

python 3 japanese letters from genfromtxt

I'm working on a programm that uses data from .txt-files and does stuff with said data. The data contains mostly latin characters, but sometimes there are also Japanese characters. That's what I want to do: # -- coding: UTF-8 -- import numpy as…
LarsK
  • 13
  • 3
0
votes
0 answers

Skip initial spaces with numpy.genfromtxt

I'm trying to read CSV files into Python with the numpy package. My row data has several entries such as 'VA, no longer in study'. The issue is that if I use np.genfromtxt to read in the file with ',' as the delimiter, it separates such entries as…
0
votes
3 answers

Read txt file with string and number columns

I have tab-separated file (city-data.txt): Alabama Montgomery 32.361538 -86.279118 Alaska Juneau 58.301935 -134.41974 Is it possible to read somehow first two columns as strings and last two as floats? My output should look like…
elenaby
  • 167
  • 2
  • 11
0
votes
0 answers

genfromtxt from numpy package doesn't work as expecting in Jupyter notebook

I have some very simple data I created that I saved in a csv file to test : 1,1.8 2,4.5 3,9.6 4,16 5,25.3 And I want to import them in Python. In IDLE this works as expected using genfromtxt from the numpy package: >>> my_data =…
DJBunk
  • 101
  • 1
  • 3
0
votes
1 answer

Trouble using Numpy genfromtxt

Hi i would like to process a data text file but i seem to be having alot of problems with the code. the text file is as follows -7 -9.000000000000002 -3 622.0582425616101 -6.500000000000001 …
0
votes
1 answer

How to convert TXT file with various columns to file a with delimiter "," using python?

I have the following ORIGINAL.TXT file: "TRACE: A" "FORMAT: WOW" "Frequency" "Data 1" "Data 2" 1 1 2 1 6 0 "Frequency" "Data 1" "Data 2" 1 5 0 1 6 0 In order to run python script, I have to first open .TXT file in…
Random Data
  • 53
  • 1
  • 9
0
votes
1 answer

genfromtext reading .csv with 3 columns returns ValueError 'got 3 columns instead of 2'?

I am wanting to import a .csv file with 3 columns where column 1 is my x values, column 2 is one series, and column 3 is another. I want to plot both series on one plot but when I try to read the csv file and plot it returns a ValueError (see…
mathwiz97
  • 67
  • 2
  • 11
0
votes
0 answers

how to np.genfromtxt a utf-8 file? python3 numpy

I have a txt file with these characters: á é í ó ú ñ and I want to make it a numpy array with np.genfromtxt and when doing it, it displays this error: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 34: ordinal not in…
Phil Rv
  • 75
  • 1
  • 1
  • 6
0
votes
1 answer

genfromtxt return numpy array not separated by comma

I have a *.csv file that store two columns of float data. I am using this function to import it but it generates the data not separated with comma. data=np.genfromtxt("data.csv", delimiter=',', dtype=float) output: [[ 403.14915 150.560364 ] […
Jeanne
  • 1,241
  • 3
  • 19
  • 28
0
votes
1 answer

Python : Reading CSV using np.genfromtxt resulting in different number of columns

I am using np.genfromtxt to read a csv. I am not sure why it is raising a ValueError(errmsg) on the data. When I read the file in excel and it shows a total of 23 columns for all the 33 rows in the file Here is the code and error: csv =…
E B
  • 1,073
  • 3
  • 23
  • 36
0
votes
1 answer

How to import and write text in a for cycle

I have the following code: dat11=np.genfromtxt('errors11.txt') dat12=np.genfromtxt('errors12.txt') dat13=np.genfromtxt('errors13.txt') dat22=np.genfromtxt('errors22.txt') dat23=np.genfromtxt('errors23.txt')…
Giulio
  • 5
  • 2