473,756 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

numpy or _numpy or Numeric?

I am a newbie here

I am trying to read "space separated floating point data" from file

I read about csv module by searching this group,
but I couldn't read space separated values with csv.
(which may be matter of course..)

I also read about numpy.fromfile( file, sep=' ') which i can use.
but on my machine(ubuntu linux) numpy is unknown module,
which I didn't install by myself.

While trying to install numpy accroding to its homepage.
(http://numpy.scipy.org/numpydoc/numdoc.htm).
i am quite confused.

it's talking about the Numerical Python,
and it says to test whether it is installed or not,
try import Numeric instead of numpy.

I got Nurmeric modules and
as a matter of fact i got a file named '_numpy.so' in lib directory.

I can import _numpy but _numpy does not have 'fromfile' method

My question is:
1. Do i need to install numpy module?
2. Then Is it different from Numeric module?
3. Then where can i get it?

4. Or what is general way to read 'space separated values' from file?

Thanks in advance.
Jan 24 '07 #1
5 4130
auditory wrote:
I am a newbie here

I am trying to read "space separated floating point data" from file

I read about csv module by searching this group,
but I couldn't read space separated values with csv.
(which may be matter of course..)

I also read about numpy.fromfile( file, sep=' ') which i can use.
but on my machine(ubuntu linux) numpy is unknown module,
which I didn't install by myself.
You will need to install NumPy.
>
While trying to install numpy accroding to its homepage.
(http://numpy.scipy.org/numpydoc/numdoc.htm).
i am quite confused.
You are reading old documentation for Numeric and so any installation
description is how to install the Numeric module (not its newer
replacement which is called NumPy).
So:

1) Yes, you need NumPy
2) This *is different* from Numeric
3) You get it by either installing a pre-built package for your system
or by

a) downloading the source tar-file from
http://sourceforge.net/project/showf...kage_id=175103
(get the numpy-<version>.tar.g z file
b) tar zxvf numpy-<version>.tar.g z
c) cd numpy-<version>
d) sudo python setup.py install

e) If you want to link against high-performance libraries on your
system, then either put them in standard locations or edit the site.cfg
file appropriately (Optional).
>
4. Or what is general way to read 'space separated values' from file?
You can easily read space-separated values from a file by reading in a
line at a time and using the split method of strings:

fid = open('filename' )
linedata = fid.readlines()
new = [[float(x) for x in line.split()] for line in linedata]

new will be a nested sequence of floats. You can convert it to an array
(if you want to do math on it) using

anew = numpy.array(new )

-Travis

Jan 24 '07 #2
On Jan 24, 2:24 am, auditory <pkyo...@gmail. comwrote:
I am a newbie here

I am trying to read "space separated floating point data" from file

I read about csv module by searching this group,
but I couldn't read space separated values with csv.
(which may be matter of course..)

I also read about numpy.fromfile( file, sep=' ') which i can use.
but on my machine(ubuntu linux) numpy is unknown module,
which I didn't install by myself.

While trying to install numpy accroding to its homepage.
(http://numpy.scipy.org/numpydoc/numdoc.htm).
i am quite confused.

it's talking about the Numerical Python,
and it says to test whether it is installed or not,
try import Numeric instead of numpy.

I got Nurmeric modules and
as a matter of fact i got a file named '_numpy.so' in lib directory.

I can import _numpy but _numpy does not have 'fromfile' method

My question is:
1. Do i need to install numpy module?
2. Then Is it different from Numeric module?
3. Then where can i get it?

4. Or what is general way to read 'space separated values' from file?

Thanks in advance.
If *all* you need is to read a space-separated file with floating point
values, installing numpy (or Numeric or numarray..) is an overkill; you
can do it in one line in pure Python:

matrix = [map(float, line.split()) for line in
open('my_space_ separated_file. txt')]

This stores the values as a list of lists, each list corresponding to a
row in the file. Depending on what you plan to do next with these
numbers, this may or may not be the best way to go about it, but since
you only mentioned the file reading part, we can't assume much.

George

Jan 24 '07 #3
George Sakkis ? ?:
On Jan 24, 2:24 am, auditory <pkyo...@gmail. comwrote:
>I am a newbie here

I am trying to read "space separated floating point data" from file

I read about csv module by searching this group,
but I couldn't read space separated values with csv.
(which may be matter of course..)

I also read about numpy.fromfile( file, sep=' ') which i can use.
but on my machine(ubuntu linux) numpy is unknown module,
which I didn't install by myself.

While trying to install numpy accroding to its homepage.
(http://numpy.scipy.org/numpydoc/numdoc.htm).
i am quite confused.

it's talking about the Numerical Python,
and it says to test whether it is installed or not,
try import Numeric instead of numpy.

I got Nurmeric modules and
as a matter of fact i got a file named '_numpy.so' in lib directory.

I can import _numpy but _numpy does not have 'fromfile' method

My question is:
1. Do i need to install numpy module?
2. Then Is it different from Numeric module?
3. Then where can i get it?

4. Or what is general way to read 'space separated values' from file?

Thanks in advance.

If *all* you need is to read a space-separated file with floating point
values, installing numpy (or Numeric or numarray..) is an overkill; you
can do it in one line in pure Python:

matrix = [map(float, line.split()) for line in
open('my_space_ separated_file. txt')]

This stores the values as a list of lists, each list corresponding to a
row in the file. Depending on what you plan to do next with these
numbers, this may or may not be the best way to go about it, but since
you only mentioned the file reading part, we can't assume much.

George
Thanks a lot for your 'elegant' suggestion.
As a next step i wish to do some math with matrix and produce a vector
and write it on a file. (in fact math is just averaging now)

I hope i can do this with a little more efforts.

Jan 24 '07 #4
Travis E. Oliphant ? ?:
auditory wrote:
>I am a newbie here

I am trying to read "space separated floating point data" from file

I read about csv module by searching this group,
but I couldn't read space separated values with csv.
(which may be matter of course..)

I also read about numpy.fromfile( file, sep=' ') which i can use.
but on my machine(ubuntu linux) numpy is unknown module,
which I didn't install by myself.

You will need to install NumPy.
>>
While trying to install numpy accroding to its homepage.
(http://numpy.scipy.org/numpydoc/numdoc.htm).
i am quite confused.

You are reading old documentation for Numeric and so any installation
description is how to install the Numeric module (not its newer
replacement which is called NumPy).
So:

1) Yes, you need NumPy
2) This *is different* from Numeric
3) You get it by either installing a pre-built package for your system
or by

a) downloading the source tar-file from
http://sourceforge.net/project/showf...kage_id=175103

(get the numpy-<version>.tar.g z file
b) tar zxvf numpy-<version>.tar.g z
c) cd numpy-<version>
d) sudo python setup.py install

e) If you want to link against high-performance libraries on your
system, then either put them in standard locations or edit the site.cfg
file appropriately (Optional).
>>
4. Or what is general way to read 'space separated values' from file?

You can easily read space-separated values from a file by reading in a
line at a time and using the split method of strings:

fid = open('filename' )
linedata = fid.readlines()
new = [[float(x) for x in line.split()] for line in linedata]

new will be a nested sequence of floats. You can convert it to an array
(if you want to do math on it) using

anew = numpy.array(new )

-Travis
Thank you for quick answer..

I found the above website from googling with "numpy" keyword,
and supprised at that the top matching page is old one.

In addition to your method and below one,
I found csv moudule can do this with "delimiter" paramter.
I made mistake not to read manual first.
My apology on that.
Jan 24 '07 #5
auditory wrote:
>>While trying to install numpy accroding to its homepage.
(http://numpy.scipy.org/numpydoc/numdoc.htm).
i am quite confused.
You are reading old documentation for Numeric and so any installation
description is how to install the Numeric module (not its newer
replacement which is called NumPy).

I found the above website from googling with "numpy" keyword,
and supprised at that the top matching page is old one.
The website is not the old one. http://numpy.scipy.org is correct.

But, the documentation is old. But, it is still useful (except for
Numeric specific information like how to install it). Therefore we
still make a link to it.

-Travis

Jan 25 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1803
by: Andrew Felch | last post by:
So I wanted to matrixmultiply , ] * Of course this is impossible, because the number of columns in the
2
3110
by: martino | last post by:
Hi, I am trying to install NumPy (v23.8) onder Macosx (panther version). Python (v2.3) is bundled into panther and I installed the IDE on top of that. After having untarred the source distribution in the desktop directory and typed >python setup.py install as recommended in the attached documentation, I get: running install
20
2584
by: mclaugb | last post by:
Has anyone recompiled the Scientific Computing package using NumPy instead of Numeric? I need a least squares algorithm and a Newton Rhaphson algorithm which is contained in Numeric but all the documentation out there says that Numeric is crap and all code should be using NumPy. Thanks, Bryan
10
2243
by: Bryan | last post by:
hi, what is the difference among numeric, numpy and numarray? i'm going to start using matplotlib soon and i'm not sure which one i should use. this page says, "Numarray is a re-implementation of an older Python array module called Numeric" http://www.stsci.edu/resources/software_hardware/numarray
15
2525
by: greg.landrum | last post by:
After using numeric for almost ten years, I decided to attempt to switch a large codebase (python and C++) to using numpy. Here's are some comments about how that went. - The code to automatically switch python stuff over just kind of works. But it was a 90% solution, I could do the rest by hand. Of course, the problem is that then the code is still using the old numeric API, so it's not a long term solution. Unfortunately, to switch to...
0
1997
by: robert | last post by:
just a note - some speed comparisons : 0.60627370238398726 0.42836673376223189 0.36965815487747022 0.016557970357098384 0.15692469294117473 0.01951756438393204
2
2796
by: robert | last post by:
in Gnuplot (Gnuplot.utils) the input array will be converted to a Numeric float array as shown below. When I insert a numpy array into Gnuplot like that below, numbers 7.44 are cast to 7.0 Why is this and what should I do ? Is this bug in numpy or in Numeric? >>m #numpy array array(, , , ..., ,
1
7515
by: Jianzhong Liu | last post by:
Hello, Guys, I have a question about the linear_least_squares in Numpy. My linear_least_squares cannot give me the results. I use Numpy1.0. The newest version. So I checked online and get your guys some examples. I did like this.
1
2450
by: adolfo | last post by:
I downloaded and installed Phyton 2.52 (it works), numpy-1.0.4.win32- py2.5, and scipy-0.6.0.win32-py2.5 I can´t get Numpy to show up at Python´s IDLE, or command line. If I do: # I get File "<pyshell#0>", line 1, in <module> import Numeric ImportError: No module named Numeric
0
9455
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9271
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9708
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7242
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5140
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5302
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2665
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.