473,666 Members | 2,324 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

writing multi dimensional array of data to text file

does anyone have any suggestions for writing a two dimensional array of
data to a file.

Currently, I have an array of 5 columns, with 1000 elements per array.
I know that I can use a for next loop to go through each data point in
the array and use the streamwriter class for each individual data point
and write each point individually to the file.

I would like to simplify this by simply writing the entire array to
file.

My array could be as big as 100,000 elements, so I'd like to find a
more efficient method,.

thanks

Jan 17 '07 #1
4 4529
Take a look at
System.Runtime. Serialization.F ormatters.Binar y.BinaryFormatt er and see if
that will help you out. Or did you need for that data to be human readable?

<da*******@yaho o.comwrote in message
news:11******** *************@m 58g2000cwm.goog legroups.com...
does anyone have any suggestions for writing a two dimensional array of
data to a file.

Currently, I have an array of 5 columns, with 1000 elements per array.
I know that I can use a for next loop to go through each data point in
the array and use the streamwriter class for each individual data point
and write each point individually to the file.

I would like to simplify this by simply writing the entire array to
file.

My array could be as big as 100,000 elements, so I'd like to find a
more efficient method,.

thanks

Jan 17 '07 #2
Ultimately it will need to be presented in a text file, and may likely
even need to be exported to Excel. If I need to save it as a binary
first and then convert to text (or numeric), so be it.

I'm really suprised that there is not a method to invoke the writing of
an entire array to a text file. Seems like it would be a common need
for programmers.

Jan 17 '07 #3
The question there is portability and reusability. Presemably, when you
write out to file for later resue you would use the same program to read it
back in. When the need arises that some other program is expected to
reconstruct the data (i.e. the human factor) then you have to be a bit more
explicit.

Is it for an IBM, then you have to export in EBSIDC
Is it for a PC, the ASCII will prolly suit you fine.
Does it need to go over the web, then perhaps XML is the key for you.
The tried and true way is as a simple Byte(), of course who can read that?

While the need may be ever present in a programmer's world, don't sell
yourself short that the solution is prewrapped. It is bad enough that a lot
of functionality is prewrapped and the libraries are bloated to the hilt.
But because we are programmers, we know how to create our own utilities to
accomplish our tasks as needed.

Rather than use an array, perhaps you can use an arraylist, or even better
system.collecti on.collectionba se? Nest your data as needed then provide a
nice little tostring() method or serialize(filen ame) method. Another option
is to pass the Array into a custom array serializer, to minimize the bloat
while you are working with the data.

<da*******@yaho o.comwrote in message
news:11******** **************@ 38g2000cwa.goog legroups.com...
Ultimately it will need to be presented in a text file, and may likely
even need to be exported to Excel. If I need to save it as a binary
first and then convert to text (or numeric), so be it.

I'm really suprised that there is not a method to invoke the writing of
an entire array to a text file. Seems like it would be a common need
for programmers.

Jan 17 '07 #4
Thanks for the suggestions.

I'm involed in a project for data acquisition, where the data is coming
into my application at high rates (can be up to 1MgHz, in chunks of a
few thousand samplesas single data types). Generally, the end user
needs to store the data to a text file or excel. As excel cannot keep
up with the higher data transfer rates (as well as excessive file
sizes), the text file is the preffered saving method. The end user
only needs to access the data via a text file format.

I'll certainly investigate some of your recommendations for a solution.

Thanks again, it is very apprecaited.

Jan 17 '07 #5

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

Similar topics

2
10681
by: iop | last post by:
Hello there, I'd like to "parse" an entire multi-dimension array like this : APP APP without knowing "framework" or "config" or anything passed as variables... 'cause it's simple to call APP.length My goal is to simply write a xml file out a javascript array... Thanks for any help !!
2
7660
by: ip4ram | last post by:
I used to work with C and have a set of libraries which allocate multi-dimensional arrays(2 and 3) with single malloc call. data_type **myarray = (data_type**)malloc(widht*height*sizeof(data_type)+ height* sizeof(data_type*)); //allocate individual addresses for row pointers. Now that I am moving to C++,am looking for something by which I can
4
4511
by: Robert P. | last post by:
I can easily store a one-dimensional array in viewstate ( see Test1 ) If I try storing a multi-dimensional array in the viewstate it's crapping out on me when it goes to serialize the array (not when I make the assignment). Interestingly, I get a very different error depending on the type of array ( string or decimal ). I'm not doing anything fancy, just a regular old aspx page with a single
4
6374
by: entitledX | last post by:
Hi, I'm trying to use the HDF library to read a few HDF files that I need to process. The data in each file varies in rows, but the columns remain constant. Because of that, I had dynamically allocated a set of pointer to pointers as my multi-dimensional arrays. Here is my code (i have omitted checking calloc's return value to make this shorter): int **filter; filter = calloc( ylength, sizeof(int*) ); for( i = 0 ; i < ylength...
4
3028
by: Balaskas Evaggelos | last post by:
Hi, does anyone know how i can sort a multi-dimensional array by a specific field ? for example i want to sort arr where n=2, but i need the data of every array to follow that order. example array: arr
8
11820
by: per9000 | last post by:
Hi all, I have a two-dimensional array of data, f.x int's. We can imagine that the array is "really large". Now I want the data in it and store this in a one-dimensional array. The obvious way to do this is a nested for-loop - but we all know O(n^2) is bad. So I am looking for something like ArrayList.ToArray(), or Matlabs A(:). C#
4
1571
by: Paul David Buchan | last post by:
Hello, I'm attempting to write a program to read in database files (.dbf). When I do it all as a single procedure in main, everything works. However, what I really want, is to pass the database filename to a function, and have it pass back an array containing the database contents, and some parameters telling me the dimensions of the array. I've succeeded in getting my function to read in the dbf file, and it returns the dimensions of...
152
9820
by: vippstar | last post by:
The subject might be misleading. Regardless, is this code valid: #include <stdio.h> void f(double *p, size_t size) { while(size--) printf("%f\n", *p++); } int main(void) { double array = { { 3.14 }, { 42.6 } }; f((double *)array, sizeof array / sizeof **array); return 0;
4
7325
by: =?Utf-8?B?SGVucmlrIFNjaG1pZA==?= | last post by:
Hi, consider the attached code. Serializing the multi-dimensional array takes about 36s vs. 0.36s for the single-dimensional array. Initializing the multi-dimensional array takes about 4s vs. 0.3s for the single-dimensional array. (I know initializing is not necessary in this simple example,
0
8878
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7389
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6200
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
5671
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
4200
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
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2776
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
2
2012
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1778
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.