Maximum number of data in Python


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Maximum number of data in Python
# 1  
Old 03-12-2015
Maximum number of data in Python

Hi all,

I would like to save my output data in two columns. I tried
Code:
print(x,y)

but have two problems:
1. There are ~10000 values for each x and y, but the intermediates are omitted;
2. I'd like to list data in two columns instead of two arrays (BTW, it's fine as I can format it using other scripts. I just want to know whether there is any "magic" Python command).

Here is the output data:
Code:
(array([  0.00000000e+00,   1.00000000e-02,   2.00000000e-02, ...,
         9.99700000e+01,   9.99800000e+01,   9.99900000e+01]), array([ 0.        , -0.00596894, -0.01193791, ..., -0.00693311,
       -0.00696012, -0.00698441]))

Any comment would be highly appreciated!

Many thanks,
Sxiong

Last edited by sxiong; 03-12-2015 at 02:42 PM..
# 2  
Old 03-12-2015
maybe a Python tuple is a better fit? (for example, an array of tuples)

Code:
tuple_array = [
  (0.00000000e+00, 0.),
  (1.00000000e-02, -0.00596894),
  (2.00000000e-02, -0.01193791)
]
print tuple_array

Produces:

[(0.0, 0.0), (0.01, -0.00596894), (0.02, -0.01193791)]

Continuing on....

Code:
for tuple in tuple_array:
   print tuple

Produces:

(0.0, 0.0)
(0.01, -0.00596894)
(0.02, -0.01193791)


Does that help?

---------- Post updated at 02:57 PM ---------- Previous update was at 02:20 PM ----------

You could also use an array (list) of lists:

Code:
list_array = [ [0.00000000e+00, 0.], [1.00000000e-02, -0.00596894], [2.00000000e-02, -0.01193791] ]

This might be better if you need to manipulate the list elements.
# 3  
Old 03-12-2015
Thanks a lot for your inputs. However, I guess I didn't state my problem clearly. The purpose of my Python script is to run certain equations with a few parameters as input, and to output the final results. So I don't have a list of data in the format of
Code:
(0.00000000e+00, 0.),   (1.00000000e-02, -0.00596894),   (2.00000000e-02, -0.01193791)

as my input.

The output is defined in the script as
Code:
x,y = CertainFunction(parameter1,parameter2)

What I need in the script is to generate the array, something like(sorry I am new to Python):
Code:
tuple_array = [x,y]
print tuple_array

or
Code:
tuple_array = [x,y]
for (x,y) in tuple_array:
  print x,y

Thanks!

Last edited by sxiong; 03-12-2015 at 06:55 PM..
# 4  
Old 03-12-2015
You have a tuple (2 items) where each is an array.

So you can loop through one of the tuple arrays for its length and just use a simple incrementing counter to output that index in each array.

Code:
xarray = your_tuple[0]
yarray = your_tuple[1]
l = len(xarray)

i=0
while (i < l):
  print "x: " + str(xarray[i]) + ", y: " + str(yarray[i])
  i += 1

Feel free to change the print to make the "columns" look like you want.
I mean you can use string formatting if you like if you want some kind of "fixed" widths style.
This User Gave Thanks to cjcox For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Maximum number of sed squeezing

Hi all, What is the maximum number of sed squeezing in one shell?? I've surprised with this message when I squeezed 50 sed in the same shell: 253: Identifier too long - maximum length is 18.This is what I've did in my sed query | sed -e "s/ 0 /Default /" | sed -e "s/ 1 ... (2 Replies)
Discussion started by: leo_ultra_leo
2 Replies

2. Shell Programming and Scripting

Maximum number from input by user

I am trying to calculate the maximum number from four numbers input by the user. I have the following code, but it does not work. It says there's an error with the last line "done". Any help would be appreciated. max=0 echo "Please enter four numbers: " for i in 1 2 3 4 do read number... (17 Replies)
Discussion started by: itech4814
17 Replies

3. Shell Programming and Scripting

Maximum number of characters in a line.

Hi, Could any one please let me know what is the maximum number of characters that will fit into a single line of a flat file on a unix. Thanks. (1 Reply)
Discussion started by: Shivdatta
1 Replies

4. UNIX for Dummies Questions & Answers

ls - maximum number of files

what is the maximum number ls can list down (6 Replies)
Discussion started by: karnan
6 Replies

5. UNIX for Dummies Questions & Answers

maximum number of arguments

Hi, What is the maximum number of arguments that could be passed to zsh ? To find out that I tried a simple script. And the maximum number of arguments that could be passed turned out to be 23394 #! /bin/zsh arg=1 i=1 subIndex=23000 while do arg=$arg" "$i i=$(($i + 1))... (9 Replies)
Discussion started by: matrixmadhan
9 Replies

6. Solaris

Maximum Number of threads suuported????

Hi, Anybody knows the maximum number of threads suuported by a process in solaris os. Please reply Thanks in advance :( (1 Reply)
Discussion started by: Agnello
1 Replies

7. Programming

maximum number of dots in a domain name

maximum number of dots in a domain name - not a sub-domain name. for example: mydomain.com ------ one dot mydomain.com.au ------ two dots do you know maximum number of dots in a domain name and could you provide a sample? thx. (1 Reply)
Discussion started by: hello20009876
1 Replies

8. UNIX for Dummies Questions & Answers

Maximum number of users allowed

How do i determen (what command) the max. number of users allowed Thanks in advance (10 Replies)
Discussion started by: siza
10 Replies

9. UNIX for Advanced & Expert Users

Maximum number of threads per user

Anybody knows how to setup Maximum number of threads per user or some other value on Sun Solaris 8. (1 Reply)
Discussion started by: s_aamir
1 Replies
Login or Register to Ask a Question

Featured Tech Videos