Home All Groups Group Topic Archive Search About
Author
24 Jun 2006 12:25 PM
gyoder
what is the prefered method of storing a dataset to a non-database file.
perhaps a binary file?

thanks

Author
24 Jun 2006 12:43 PM
r norman
On Sat, 24 Jun 2006 08:25:18 -0400, "gyoder" <georgeyo***@comcast.net>
wrote:

>what is the prefered method of storing a dataset to a non-database file.
>perhaps a binary file?
>

The CSV file (comma separated values) format is convenient and widely
recognized.  In general, it is a flat text file, one record per line,
with values separated by commas and strings enclosed in quotes.  See
  http://www.creativyst.com/Doc/Articles/CSV/CSV01.htm#FileFormat
for more details.

Many databases can import these files directly with no further effort
on your part except to make sure that the fields in the file
correspond to the columns in the database.
Author
24 Jun 2006 1:05 PM
gyoder
i really have no need to import the data into a database. i want to be able
to save/store it and reload it again along with other data. so the file
would contain data from the dataset and also other data.

Show quote
"r norman" <NotMyRealEmail@_comcast.net> wrote in message
news:skcq929ms33mur2bg8k15s0o31a2a2g4mj@4ax.com...
> On Sat, 24 Jun 2006 08:25:18 -0400, "gyoder" <georgeyo***@comcast.net>
> wrote:
>
>>what is the prefered method of storing a dataset to a non-database file.
>>perhaps a binary file?
>>
>
> The CSV file (comma separated values) format is convenient and widely
> recognized.  In general, it is a flat text file, one record per line,
> with values separated by commas and strings enclosed in quotes.  See
http://www.creativyst.com/Doc/Articles/CSV/CSV01.htm#FileFormat
> for more details.
>
> Many databases can import these files directly with no further effort
> on your part except to make sure that the fields in the file
> correspond to the columns in the database.
>
>
>
Author
24 Jun 2006 1:22 PM
r norman
Show quote
On Sat, 24 Jun 2006 09:05:17 -0400, "gyoder" <georgeyo***@comcast.net>
wrote:


>"r norman" <NotMyRealEmail@_comcast.net> wrote in message
>news:skcq929ms33mur2bg8k15s0o31a2a2g4mj@4ax.com...
>> On Sat, 24 Jun 2006 08:25:18 -0400, "gyoder" <georgeyo***@comcast.net>
>> wrote:
>>
>>>what is the prefered method of storing a dataset to a non-database file.
>>>perhaps a binary file?
>>>
>>
>> The CSV file (comma separated values) format is convenient and widely
>> recognized.  In general, it is a flat text file, one record per line,
>> with values separated by commas and strings enclosed in quotes.  See
>>  http://www.creativyst.com/Doc/Articles/CSV/CSV01.htm#FileFormat
>> for more details.
>>
>> Many databases can import these files directly with no further effort
>> on your part except to make sure that the fields in the file
>> correspond to the columns in the database.
>>
>i really have no need to import the data into a database. i want to be able
>to save/store it and reload it again along with other data. so the file
>would contain data from the dataset and also other data.
>
(I have taken the liberty of "correcting" your top-posting because
this is the style I prefer)

Converting everything from whatever format  to ASCII for storing files
and then back again when reading them is a big pain.  However, being
able to easily read the files and so verify that they are being
written correctly or chasing down a tricky bug in finding that the
value you read back is not the same as the value you write can be a
real lifesaver.  Also you never know whether, sometime in the future,
you might want to import the data into a database or spreadsheet.  I
find that doing the work of making human-readable files is paid back
many times over.  You don't have to make them "user friendly"
readable,  only "readable if you have the details of what fields are
in what order."

That being said, the simplest way of saving the data is to create a
fixed-length data structure to store all the data and then write and
read binary files just by byte-copying the data structure to the file
and reading it back into the data structure. 

Or, I should say, that is the simplest way for me.  What is
"preferred" is whatever you can do easily and works without error.
There are no problems provided you are absolutely sure that only your
software is ever going to do both the reading and the writing.  If you
ever have to send a file to somebody else for reading and it is a
binary file, you cannot be sure even that the same source code
compiled with a different compiler or even a different version of the
same compiler will produce a program that can read the binary file
unless you take great care in its design.  You cannot also be sure
that a file you wrote a few years back with one compiler will be
readable now with recompiled software.  The portability factor alone
is worth going with the CSV type file.

Note: in the olden days, it was quite simple:   you used printf()  to
write each line and sscanf()  with the same format  statement to read
the  lines.  It is a little more work now with streams but the same
idea applies; make the stream out and the stream in statements exactly
parallel and it should work.
Author
24 Jun 2006 1:17 PM
Simon Smith
Show quote
>
>On Sat, 24 Jun 2006 08:25:18 -0400, "gyoder" <georgeyo***@comcast.net>
>wrote:
>
>>what is the prefered method of storing a dataset to a non-database file.
>>perhaps a binary file?
>>
>
>The CSV file (comma separated values) format is convenient and widely
>recognized.  In general, it is a flat text file, one record per line,
>with values separated by commas and strings enclosed in quotes.  See
http://www.creativyst.com/Doc/Articles/CSV/CSV01.htm#FileFormat
>for more details.
>
>Many databases can import these files directly with no further effort
>on your part except to make sure that the fields in the file
>correspond to the columns in the database.
>

Of course the easiest way is to save it as an XML file - WriteXML(string
fileName) as I recall.
Author
24 Jun 2006 1:16 PM
Cowboy (Gregory A. Beamer)
The DataSet is XML, which is rather easy to read. If you are talking local
storage to be used like a database, it would depend on the size, however, as
a huge DataSet would take awhile to load. For local storage, I would
consider some "light" database engine. There are a few open source
implementations that would work.

Without knowing more about the project, that is about all I can offer.

--
Gregory A. Beamer

*************************************************
Think Outside the Box!
*************************************************
Show quote
"gyoder" <georgeyo***@comcast.net> wrote in message
news:faWdnfkMbMq7sgDZnZ2dnUVZ_tidnZ2d@comcast.com...
> what is the prefered method of storing a dataset to a non-database file.
> perhaps a binary file?
>
> thanks
>
>
Author
24 Jun 2006 1:17 PM
Miha Markic [MVP C#]
Serialization is the way to go. Either XML or binary (assuming you are on
..net 2.0). There is also DataSet.WriteXml/ReadXml pair you might find
convenient.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Show quote
"gyoder" <georgeyo***@comcast.net> wrote in message
news:faWdnfkMbMq7sgDZnZ2dnUVZ_tidnZ2d@comcast.com...
> what is the prefered method of storing a dataset to a non-database file.
> perhaps a binary file?
>
> thanks
>
>
Author
24 Jun 2006 8:47 PM
gyoder
Could you please expand upon "serialization". Perhaps binanry. Im on .net
2.0.

Thanks


Show quote
"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:OxSRaC5lGHA.1488@TK2MSFTNGP02.phx.gbl...
> Serialization is the way to go. Either XML or binary (assuming you are on
> .net 2.0). There is also DataSet.WriteXml/ReadXml pair you might find
> convenient.
>
> --
> Miha Markic [MVP C#, INETA Country Leader for Slovenia]
> RightHand .NET consulting & development www.rthand.com
> Blog: http://cs.rthand.com/blogs/blog_with_righthand/
>
> "gyoder" <georgeyo***@comcast.net> wrote in message
> news:faWdnfkMbMq7sgDZnZ2dnUVZ_tidnZ2d@comcast.com...
>> what is the prefered method of storing a dataset to a non-database file.
>> perhaps a binary file?
>>
>> thanks
>>
>>
>
>
Author
25 Jun 2006 7:26 AM
Miha Markic [MVP C#]
Hi,

Here you'll find an example:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=204833&SiteID=1

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Show quote
"gyoder" <georgeyo***@comcast.net> wrote in message
news:Q8mdnfh83KRuOQDZnZ2dnUVZ_tadnZ2d@comcast.com...
> Could you please expand upon "serialization". Perhaps binanry. Im on .net
> 2.0.
>
> Thanks
>
>
> "Miha Markic [MVP C#]" <miha at rthand com> wrote in message
> news:OxSRaC5lGHA.1488@TK2MSFTNGP02.phx.gbl...
>> Serialization is the way to go. Either XML or binary (assuming you are on
>> .net 2.0). There is also DataSet.WriteXml/ReadXml pair you might find
>> convenient.
>>
>> --
>> Miha Markic [MVP C#, INETA Country Leader for Slovenia]
>> RightHand .NET consulting & development www.rthand.com
>> Blog: http://cs.rthand.com/blogs/blog_with_righthand/
>>
>> "gyoder" <georgeyo***@comcast.net> wrote in message
>> news:faWdnfkMbMq7sgDZnZ2dnUVZ_tidnZ2d@comcast.com...
>>> what is the prefered method of storing a dataset to a non-database file.
>>> perhaps a binary file?
>>>
>>> thanks
>>>
>>>
>>
>>
>
>

AddThis Social Bookmark Button