473,387 Members | 1,798 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,387 software developers and data experts.

How to save and read very big Array Value to/from file in VB.NET?

str_Array() 'strings
I need save it to file and next time i can read from file.

--------------------------------------------------------
--------------------------------------------------------
Save Function
I use
str_FromAndToFile=join(str_Array,"VBTAB")
--------------------------------------------------------
Read Function
I use
str_Array=Split(str_FromAndToFile,"VBTAB")
--------------------------------------------------------
--------------------------------------------------------

The problem is more str_Array() huge ,the code run more slowly.

some cost value
(C1.7-512M)
str_Array(i) Read Cost Save Cost.
100000 1.2s 1.5s
1000000 2s 13s
....

Actually I need i=1'000'000'000. :-(
Could anyone help me to improve it or give me some efficiency source code?

THX!

on************@hotmail.com
Nov 20 '05 #1
4 9441
Hi

Why are you not using an arraylist and read/write that as normal records
using the streamreader/streamwriter

http://msdn.microsoft.com/library/de...ClassTopic.asp

http://msdn.microsoft.com/library/de...ClassTopic.asp

http://msdn.microsoft.com/library/de...classtopic.asp

I hope this helps?

Cor
Nov 20 '05 #2
* "=?Utf-8?B?b25jZWxvdmVjb2ZmZWU=?=" <on************@discussions.microsoft.com> scripsit:
I need save it to file and next time i can read from file.


'FileOpen', 'FileGet', 'FilePut', ...

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3
oncelovecoffee,
In addition to the other comments, I would iterate over the array & write
each element as a line.

To read it back I would simply read each line.

I would consider using an ArrayList as they automatically expand as needed.

Something like:

Imports System.IO
Imports System.Text

Dim str_Array As New ArrayList

Dim input As New StreamReader("myfile.in", Encoding.Default)
Dim line As String = input.ReadLine()
Do Until line Is Nothing
str_Array.Add(line)
line = input.ReadLine()
Loop
Dim output As New StreamWriter("myfile.out", False,
Encoding.Default)

For Each line As String In str_Array
output.WriteLine(line)
Next
Actually I need i=1'000'000'000. :-( However if you really have a billion lines, you may want to consider
upgrading to .NET 64 bit edition, as 32 bit .NET only supports 2G of memory.

http://lab.msdn.microsoft.com/vs2005/

Unfortunately the 64 bit edition is only available as Beta 1 currently, you
will need to wait until sometime in 2005 for the release.

Alternatively consider reading only the line you need to work on and write
it.
Dim input As New StreamReader("myfile.in", Encoding.Default)
Dim output As New StreamWriter("myfile.out", False,
Encoding.Default)
Dim line As String = input.ReadLine()
Do Until line Is Nothing
' do something with line
output.WriteLine(line)
line = input.ReadLine()
Loop

Hope this helps
Jay

"oncelovecoffee" <on************@discussions.microsoft.com> wrote in message
news:5A**********************************@microsof t.com... str_Array() 'strings
I need save it to file and next time i can read from file.

--------------------------------------------------------
--------------------------------------------------------
Save Function
I use
str_FromAndToFile=join(str_Array,"VBTAB")
--------------------------------------------------------
Read Function
I use
str_Array=Split(str_FromAndToFile,"VBTAB")
--------------------------------------------------------
--------------------------------------------------------

The problem is more str_Array() huge ,the code run more slowly.

some cost value
(C1.7-512M)
str_Array(i) Read Cost Save Cost.
100000 1.2s 1.5s
1000000 2s 13s
...

Actually I need i=1'000'000'000. :-(
Could anyone help me to improve it or give me some efficiency source code?

THX!

on************@hotmail.com

Nov 20 '05 #4
At last ,I use the policy "Used, Record it",if one of the array member's value is default .then I don't touched it:-)
:EXAMPLE
0 XXX
1 XXX
2 DEFAULT
3 DEFALUT
..
..
..
999999999 XXX
1000000000 DEFALUT

i record

0 XXX
1 XXX
..
..
999999999 XXX

it reduce the size of file and save time to write file.
the worst conditation is I still should record them all if every value changed
:-(

And good news is 1000 times Rnd test shows about 30% of array members's value changed (AVG). :-)
Nov 20 '05 #5

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

Similar topics

6
by: BadOmen | last post by:
I have a text file that I want to save from my program. But I don't want to save the empty lines. I want to delete everything after the last character, Is that possible? Then when I read the...
4
by: Andras Gilicz | last post by:
Hi VB fans I'm working on a relatively large project in VB6 with about a dozen forms, including graphs, labels, text boxes, etc. The software itself is actually a flow simulator with more or...
1
by: Andy Jacobs | last post by:
Hi, I have a row in a DataTable that contains colums of identifying data and I need to save a bitmap in that row. (I'm going to write the entire DataSet to disk as XML to be used by another...
2
by: Duy Nguyen | last post by:
how can I save an image file to database?
3
by: Stefano | last post by:
I've a form windows with a lot of textbox controls. How can I do if I have to save all text proprety of this controls in an external file, to reload them in future?
8
by: david.lindsay.green | last post by:
Hello all, I am quite new a web scripting and making web pages in general and I have stumbled across a problem I have as yet been unable to solve. I am trying to take the contents of a textarea box...
3
by: =?Utf-8?B?Um9nZWxpbw==?= | last post by:
I'm having the wierdest problem. I'm trying to save images into a SQL 2005 database. the field is just called "IMAGES" and hte data type is "image". here is my code to save //following code...
11
by: Lamer | last post by:
I was wondering how to save PHP variables to a txt file and then retrieve them again. Example: There is an input box, after submitted the stuff that was written in the input box will be saved...
10
by: Gilles Ganault | last post by:
Hello Out of curiosity, is there a smarter, easier way to read data sent by a form, and save them into a database? I have about 20 fields, and it'd be easier if I could just use a loop to go...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.