Jump to content

Reading ini files


 Share

Recommended Posts

any faster way to read *.ini files. i have a ini file with 10,00,00 lines. how to read it fast?

my ini file have no section only some paths like

C:\Dir1\Dir2\Dir4\Audio\Song.MP3
D:\Videos\YouTube\Old\Love.FLV
E:\Software\AutoIt\Setup.EXE
F:\Themes\NewThemes\Vista\AeroGlass.THM
;and so on........

how can i read it faster?

Thankss.

Link to comment
Share on other sites

i could not understand, can you please explain more?

FileOpen() is for opening files. Read the help file on FileOpen().

FileRead() is for reading files (perhaps after opening them with FileOpen). Read the help file on FileRead().

To read larger parts of the INI file you might try IniReadSection(), providing no individual section is more than 32K. Read the help file on IniReadSection().

Win16 compatibility had limited AutoIt's ability to use large INI files. There has bee talk of removing Win16 backward compatibility (Pre-WinNT: Win98 and Win95) so that may change, providing you are not using those older OS versions. This limitation only applied to INI files, and not regular file read/write operations. Read the comments and change logs in the help file.

Also, read your help file.

:P

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

To read larger parts of the INI file you might try IniReadSection(), providing no individual section is more than 32K. Read the help file on IniReadSection().

my file have no section and i am using a text (*.txt) file instead of ini (*.ini) files because ini file have limitations but txt file have not.

anyways... i know how to read these files but i need a fast way to do it. a code which can read the file very fast or at least better then reading it direct (Default).

Thankss.

Link to comment
Share on other sites

my file have no section and i am using a text (*.txt) file instead of ini (*.ini)

If it is a text file it is not an ini file. An ini file has at least one section. Explain what you want to do (what is your goal?) and somebody will help you out 1st reading and 2nd parsing your text file.

Link to comment
Share on other sites

i have a application which reads the text file. there are some paths stored in the text file for images,songs,videos,applications,etc like

C:\Dir1\Dir2\Dir4\Audio\Song.MP3
D:\Videos\YouTube\Old\Love.FLV
E:\Software\AutoIt\Setup.EXE
F:\Themes\NewThemes\Vista\AeroGlass.THM
;and so on........

my application reads the file and tells if this file is already opened or not. on first time opening a file my application writes the path of file to the text file and then reads it to show if it is already opened or if this is it's first start.

but the text file have many paths stored in it, and when application reads it takes some time to read the whole file for paths.

i need something which can read the file very fast.

any faster way to read *.txt files. i have a text file with 10,00,00 lines. how to read it fast?

my text file is like ini files but it have no section.

Link to comment
Share on other sites

i have a application which reads the text file. there are some paths stored in the text file for images,songs,videos,applications,etc like

C:\Dir1\Dir2\Dir4\Audio\Song.MP3
D:\Videos\YouTube\Old\Love.FLV
E:\Software\AutoIt\Setup.EXE
F:\Themes\NewThemes\Vista\AeroGlass.THM
;and so on........

my application reads the file and tells if this file is already opened or not. on first time opening a file my application writes the path of file to the text file and then reads it to show if it is already opened or if this is it's first start.

but the text file have many paths stored in it, and when application reads it takes some time to read the whole file for paths.

i need something which can read the file very fast.

Okay...so what about "_FileReadToArray"? This function, you btw. need to include <file.au3>, reads every line of a text file into an array. After that you could check for open files using the elements of the array.

Link to comment
Share on other sites

Maybe instead of just directly storing the values to a ini file without any order you arrange them into alphabetical order?

You could do this by adding sections to your ini file (A, B, C, D, E, etc...)

Then add the lines to the sections via either their Drive letter or the folder? Will make it much quicker if you sort of the file instead of just adding them higguldy pigguldy.

Click here for the best AutoIt help possible.Currently Working on: Autoit RAT
Link to comment
Share on other sites

From what I understand of your requirements it would be better to use a dictionary object if you have a large number of items in your list to check. This has the advantage of taking an almost constant time to find the item no matter how many items are in the list. There is a little bit of overhead associated with each lookup so if you only have a few items then your current method will be slightly faster, but for larger numbers of items the dictionary object will be much faster.

Modify this snippet of code to suite your needs.

Global $g_oFilesOpendDic = ObjCreate("Scripting.Dictionary")

Func FileOpend($sFileName_In)
    Local $sFieldName = ''
    If $g_oFilesOpendDic.Exists($sFileName_In) Then
        Return True ; file is in list
    Else
            ;Add file to list
            $g_oFieldMapDic.Add($sFileName_In, $sFileName_In)
        Return False ; File was not in list
    EndIf
Func

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...