473,395 Members | 1,885 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Python/Numpy: Automating to save generated data

10 Byte
I want to save a particular number of values in maps I create. For example, when creating (4064x1) values, I want to save first (1000x1) in map1, next (1000x1) in map2 and so on. The last map will have remaining (64x1) elements. I need these maps later for fast processing.

Now the issue is I want to automate this as the number 4064 varies based on data I analyze. Here is simplsitic version of something I tried and is working (L is 1000 and index is reset to zero as I move from one map to the other).

Any suggestions on how to make this creative?
Expand|Select|Wrap|Line Numbers
  1. L = 1000
  2. index = 0
  3. count = 0
  4. # manually creating maps
  5. fp1 = np.memmap('map1.dat', dtype='float64', mode='w+', shape=(L,1))
  6. fp2 = np.memmap('map2.dat', dtype='float64', mode='w+', shape=(L,1))
  7. fp3 = np.memmap('map3.dat', dtype='float64', mode='w+', shape=(L,1))
  8. ...
  9. # manually pushing generated values into created maps
  10. if count < L:
  11.     fp1[index,0] = delta # delta is some float64 value I am creating in each iteration of a parent loop
  12.  
  13. if count == L:
  14.     index = 0
  15.  
  16. if L <= count < 2*L:
  17.     fp2[index,0] = delta
  18.  
  19. if count == 2*L:
  20.     index = 0
  21.  
  22. if 2*L <= count < 3*L:
  23.     fp3[index,0]=delta
  24.  
  25. ...
  26.  
  27. count += 1
  28. index += 1
Aug 11 '20 #1
1 2343
Banfa
9,065 Expert Mod 8TB
Questions
  1. Your text seems to suggest splitting an existing block of data in chunks of 1000 but your code seems to suggest generating values 1 at a time and dynamically creating new memory maps when a new value tips over the threshold. Which is it because they will require different solutions? The second scenario requires code that maintains state.
  2. Do you need to be able to access all the memmaps after the process is finished or once finished does nothing further happen so for example there is no need to be able to access the first memmap once you have started creating the second?
Aug 12 '20 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: SOAP | last post by:
how to save binary data to database by using CMP2.0? I would like to save a save image to database through EJB. but I don't know which data type shoud I use. any examples? thanks a lot
1
by: Mohsin | last post by:
Hi, any one can help me to save visual Basic Data in Access to link through Data control or ODBC. when i am trying to save vb data in Access after making link through data control it is not saving...
5
by: manuhack | last post by:
I've written a program in Python to get some data from a website. The data structure is as follows. Every day there are new data. For each day, there are many stocks. For each stock, there are...
6
by: sirimanna | last post by:
hi, is any one can help me? i have create a form and it have 3 text boxes..and i want to type some data in that text boxes and when i click save button i want to save that data in my form...i don't...
2
by: lbolla | last post by:
take a look at Python vs Matlab comparison for numerical computations: numerical-computing-matlab-vs-python+numpy+weave it seems that what stated in a previous thread was true! Python+Numpy...
3
by: NelsonP | last post by:
Hi Folks, This is my first post so please be patient with me. I am not a developer but trying to look for some guidance and think you might be able to help me. One of the functions of our Access...
5
by: sirimanna | last post by:
hello, i'm new to VB...i like to know how to open some text data save in c: in to text box.. i know to save cord's to save data in text box in to c:..but i don't know how to get back that save...
1
daniel aristidou
by: daniel aristidou | last post by:
Ok ,Hi........... Question: in vb08 how would you save modified data after it has been modified on a Datagridviewer. This really bugs me since i just finished hole database in vb but then in...
0
by: leelaprasad9999 | last post by:
Hi Can any one help me to save datagridview data with image without database using c#.net(Windows Forms) ? Is it Possible ? or anyother way to save it? . Actually i'm developing a software...
0
by: JakeFrom98 | last post by:
Hello so I'm trying to make a basic notepad in tkinter but I'm having issues with the save function. So if a files opens in the notepad I'd like to be able to press save and it will save the data...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.