Page 1 of 1 1
Topic Options
#28737 - 2002-09-09 10:46 PM INI output
Anonymous
Unregistered


I see a lot of scripts that spit data out in the classic Windows INI format. Why is this done? Do you read the data in a special program or database? What're the pros of spitting data out in INI format vs something like one big tab delimited file?

I'm doing a hardware/software inventory pretty soon and I'm wondering how I should output the data so that I can read it. I was going to do 1 tab delimited file per workstation and then concactinate them all into one file and suck it into Access. But that makes for one hell of a long WRITELINE line. The INI output seems more attractive, but I don't know how I'd get it into a database.

Thanks.

Top
#28738 - 2002-09-09 10:55 PM Re: INI output
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
The INI format allows you to use APIs to put and get data.  That way there's no need to parse through long files and also eliminates duplicate records.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#28739 - 2002-09-09 11:46 PM Re: INI output
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
I see a .INI file as a very lightweight database with limited search capability because of the format:
code:
[section1]
key1=value1
key2=value2
[section2]
key1=value1

Will allow me to get a list of sections, then I can select a specific key in a specific section and/or the correcponding value. Additionally, I only need two functions to read/write to it and I can retrieve multiple sections or keys at the same time.
_________________________
There are two types of vessels, submarines and targets.

Top
#28740 - 2002-09-10 05:30 PM Re: INI output
Anonymous
Unregistered


Pardon the ignorance, but what do you use to read and write to INI files? Are there any programs that do that? I don't mean text editors, but database progs for INI files.
Top
#28741 - 2002-09-10 06:04 PM Re: INI output
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
[Confused]
In KiXtart you would use READPROFILESTRING and WRITEPROFILESTRING and if I need to otherwise edit a .INI file I use Notepad.

there might be specila .INI Editors otu there but I never had the need for any of those since it's just a plain text file anyway.

[ 10. September 2002, 18:04: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.

Top
#28742 - 2002-09-10 06:31 PM Re: INI output
Anonymous
Unregistered


I guess I'm just not clear on why you would put data in an INI file if there's no progs to display the data other than a text editor.

I was thinking that there might be a program to read a bunch of INI files with the same formatting and show you the data all neat like.

My only experience with data in text files would be with tab or comman delimited files that can be queried with Access or Excel or MSQuery, etc. I thought you could do that INI files.

Top
#28743 - 2002-09-10 06:40 PM Re: INI output
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
The beauty of INI files is in simplicity to write/read to/from them.  In KiX, that would be WriteProfilesString() and ReadProfilesString().  Other methods require you to parse the file.  If a line is to be replaced, then the whole file needs to be rewritten.  The best is to use INIs as temporary data collections.

Generally, one would not want to let users have enough rights to a data file to muck with and possibly wipe out large amounts of data.  The client writes out to INI files and then an admin script consolidates the info into CSV or DB format.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#28744 - 2002-09-10 06:41 PM Re: INI output
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
If I need to create a fancy display of a .INI file, then I'd write a script with KiXtart tailored to the specific .INI file. However,a .INI file is not a database, it just can be used is a similar fashion as a database.

If you want to e.g. inventory your software and run different queries against the inventory, then a database approach like Access or SQL-capable database servers might be a better way for you.

You choose your tools acording to the requirements and your requirements might be better solved with a database.
_________________________
There are two types of vessels, submarines and targets.

Top
#28745 - 2002-09-10 06:49 PM Re: INI output
Anonymous
Unregistered


Ok, Les, Jens, I got it. I can use a script to write my software/hardware inventory info to an INI file for each PC. Then I use another script to put all of the info in each INI file into a tab/comman delimited file which I then can query with Access or somewhat.

Now to figure out how to read INI files and put the data in a CSV or somesuch.

Thanks!

Top
#28746 - 2002-09-10 07:14 PM Re: INI output
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
if you check the readprofilestring, with it you can get all the keys and values in those keys pretty simply.

all it takes is a loop:
$keys=readprofilestring($file,"",...)
for each $key in $keys
$values=readprofilestring($file,$key,"")
$rc=writeline(1,@crlf+$key)
for each $value in $values
$valuedata=readprofilestring($file,$key,$value)
$rc=writeline(1,$valuedata+";")
next
next
_________________________
!

download KiXnet

Top
#28747 - 2002-09-10 07:31 PM Re: INI output
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Of course if you need a e.g. TAB-delimited file anyway in the end then you do not need to first write it into a .INI file. You could write directly into a TAB-delimited file.
_________________________
There are two types of vessels, submarines and targets.

Top
#28748 - 2002-09-10 07:37 PM Re: INI output
Anonymous
Unregistered


Well, what I've been doing is writing a text file with one line per PC (per PC that runs the script). The data is tab delimited with the workstation name being the first bit of data.

When the script runs it checks to see if the file (which is named after the workstation) exists. If it does, it skips the script.

When all the PCs are inventoried, I copy all the files into one big text file and import that file into Access.

I'd write the data to one text file, but I don't know how to check if there's already an entry in the text file for the PC that's running the script.

So I thought as long as I was writing one file per PC would there be some advantage to doing it in INI format. Then I started this thread.

I'm really not very good at this scripting stuff.

Top
#28749 - 2002-09-10 08:00 PM Re: INI output
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
the point with the ini-thing is to get it easily done without any checks needed.

and to convert it to csv, you need only somewhat the stuff I wrote above. you can even make the access or whatever tool you are using to first call kix with that script... you know, translate it on the fly.
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.074 seconds in which 0.036 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org