Re: Fastest way to access data from a file.

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Ignacio X. Domínguez (ignacioxd_at_cantv.net)
Date: 09/14/04


Date: Tue, 14 Sep 2004 10:23:49 -0400

Hi tocayo (hehehe), Why do you think a simple text file is better than a XML
in this case? The problem I see with the text file is the special separator
character, because it is going to limit somehow what the strings in each
entry can contain (can't have that char). Therefore, I need to make sure in
code that the strings being stored in the text file never contain that
character. I know I can use any weird character making it unlikely that it
will be chosen by any user, but there is still a chance.

What are your thoughts about this?

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:OzbtBXlmEHA.3608@TK2MSFTNGP09.phx.gbl...
> Hi tocayo :)
>
> The fastest way is to having it in memory, you could create a struct with
> two members ( name, number) and have an ArrayList of them.. you read them
> at
> the beggining and after that all is from memory.
>
> if for some reason you cannot have them in memory the best way would be
> keeping a text file, not a XML, in the text file you keep one record per
> line, and divide the fields using a special char. For further performance
> you should put the field you will search for first and make it a fixed
> length. in this way you can use String.SubString instead of String.Split
>
> Ayway , the best way is to keep them all in memory. even so I think that
> the
> XML is not very good idea here.
>
> Cheers,
>
> --
> Ignacio Machin,
> ignacio.machin AT dot.state.fl.us
> Florida Department Of Transportation
>
>
>
> "Ignacio X. Domínguez" <ignacioxd@cantv.net> wrote in message
> news:%23wfstEhmEHA.644@tk2msftngp13.phx.gbl...
>> Hi. I'm developing a desktop application that needs to store some data in
> a
>> local file. Let's say for example that I want to have an address book
>> with
>> names and phone numbers in a file. I would like to be able to retrieve
>> the
>> name by searching for a given phone number the fastest I can.
>>
>> I have considered the posibility of using XmlTextReader with something
> like:
>>
>> <list>
>> <item number="1234567">
>> <name>John Doe</name>
>> </item>
>> <item number="9876*">
>> <name>Jane Doe</name>
>> </item>
>> </list>
>>
>> or a simple text file with entries separated by special characters:
>>
>> 1234567~John Doe%9876*~Jane Doe%
>>
>> and then use Split("%".ToCharArray()) to get an array of items, and then
>> Split("~".ToCharArray()) on every item to get name and number.
>>
>> I this database will have around 200 entries (name and number in this
>> example), so I would like to know which one do you think will perform
> faster
>> and better on most configurations.
>>
>> Thank you in advance.
>>
>> Ignacio X. Domínguez
>>
>>
>
>



Relevant Pages

  • Re: Putting a "<" in an attribute value (was about CDATA sections)
    ... > are ambiguous (section 2.4 essentially says numeric character ... is a lawyer :-) XML has inherited these definitions with very few ... Once validity is established, an application will receive ... <!DOCTYPE header [ ...
    (comp.text.xml)
  • Re: Future of LISP. Alternative to XML. Web 3.0?
    ... I didn't realize it meant literally the cr character within the ... instead of XML representation for queries and responses. ... using s-expressions instead of XML, nobody is going to use it, ... Do *any* of those LISP projects have a server I ...
    (comp.lang.lisp)
  • Re: Database for C#?
    ... I want the XML file that .Net generates to have separate Nodes for each language so that we can selectively load only the language text values for the language that the user selects for the Add-in. ... That will reduce the memory and make it quicker to load. ... <XMLData> ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: System.ArgumentException: Illegal characters in path
    ... But I don't use any xml string at all in my web ... It is a default data type string and I wonder it ... cannot accept latin character since string accepts all utf-8 characters. ... Microsoft XML 3.0 SP1 ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: Suppressing character entity transformation
    ... I was gently chastizing Pavel for a minor stylistic point. ... When XSLT reads in a document, character references and entity references are expanded; when it writes the document back out as either XML or HTML, it should re-create character references where they're necessary. ... You really want to fix that, along the lines he illustrated (issuing actual elements rather than text that looks like tags) before you do anything else. ...
    (comp.text.xml)