#100771 - 2003-05-07 06:47 PM
How do I check a CSV for a string?
|
MaestroG
Fresh Scripter
Registered: 2002-12-30
Posts: 28
Loc: Tulsa, OK
|
I read the comments on the latest KixGolf tourney thread, but it's all way over my head.
My KiXtart logon script creates a CSV to record PC information (like OS and computer name) when a user logs on. I only want one entry per computer so after that section of code runs I create a file on the C:\ drive of the PC. I also put an "If Exist" statement before that section of code and if all goes well, I only get one entry per PC in the CSV.
This seems hokie. Couldn't I do something similar like an If Instr() to look inside the CSV for that computer name if not found, run the code? I know If Instr() won't work, but is there something that does or some way to accomplish this?
I appreciate this forum. Thanks, G
|
|
Top
|
|
|
|
#100773 - 2003-05-07 07:08 PM
Re: How do I check a CSV for a string?
|
MaestroG
Fresh Scripter
Registered: 2002-12-30
Posts: 28
Loc: Tulsa, OK
|
Cool! I like the ini file idea. Do you know if there is documentation out here somewhere about the procedures and the gotchas for this new way?
|
|
Top
|
|
|
|
#100774 - 2003-05-07 07:12 PM
Re: How do I check a CSV for a string?
|
Howard Bullock
KiX Supporter
   
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Nothing hard here. Check out ReadProfileString and WriteProfileString.
|
|
Top
|
|
|
|
#100776 - 2003-05-07 08:36 PM
Re: How do I check a CSV for a string?
|
MaestroG
Fresh Scripter
Registered: 2002-12-30
Posts: 28
Loc: Tulsa, OK
|
Thanks guys!
It does look pretty straight forward and painless.
Cudos!
|
|
Top
|
|
|
|
#100778 - 2003-05-08 01:37 AM
Re: How do I check a CSV for a string?
|
BoxKite
Da Box
   
Registered: 2000-05-17
Posts: 282
Loc: Vacaville,CA,USA
|
|
|
Top
|
|
|
|
#100781 - 2003-05-08 05:43 PM
Re: How do I check a CSV for a string?
|
MaestroG
Fresh Scripter
Registered: 2002-12-30
Posts: 28
Loc: Tulsa, OK
|
That's a good point. I am writing the current CSV as one file in a central location that all open and write to. I don't know if there are lock issues going on or not. Like I said...the whole thing is hokie. I'm a novice KiXtart'er so my stuff is rudimentary at best because I patch borrowed code together until it does what I want!
Anyway...at present, the script gets PC Info and writes it to a CSV on my server and then copies a file from my server to the C:\ drive of the user's PC. Next time they logon, it checks for that copied file on local C:\ and if there, skips the code that gets info and writes to the CSV.
I am all about leaving the end-user PC out of the mix. I'd rather have the Kix logon script write the PC Info to a file of some kind and then next time around do it again and overwrite the previous data for that particular PC...its own entry (I thought of CSV only because was easy to make into a nice spreadsheet). That way, every logon gathers PC data and if something has changed, it is updated.
It seems INI file idea may help me accomplish this, but there still is the file lock question. What happens when 250 people logon at the same time?
BTW - here's my current code...
code:
If Exist($systemdrive+'\pcdata.ok') Gosub "End" Else Gosub "WriteInfo" EndIf
:WriteInfo $s = OpenFile("\\server\share\file.csv", "W", 1, 0) If @error = 0 WriteLine($s, "@DATE, @TIME, @WKSTA, @USERID, @FULLNAME" + @CRLF) Close($s) EndIf Copy $Netlogon+'\tempfile.tmp' $systemdrive+'\pcdata.ok'
Anyone have any good ideas?
|
|
Top
|
|
|
|
#100784 - 2003-05-09 03:00 AM
Re: How do I check a CSV for a string?
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11631
Loc: CA
|
Maestro,
Here is another example of what you appear to want to do.
Writing to a CSV file http://www.kixtart.org/board/ultimatebb.php?ubb=get_topic;f=1;t=007117
This is about the EASIEST (not the only way) for someone that is new to KiXtart.
Jens has a lot of good ideas and code, but updating a databse during logon is not a beginner task.
Please read the full posting on the above topic.
|
|
Top
|
|
|
|
#100786 - 2003-05-09 08:40 PM
Re: How do I check a CSV for a string?
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11631
Loc: CA
|
Well I have not tried, but I would assume that a single .ini file being updated by 1,000+ users at the same time might be an issue for file lock.
Another reason I personally don't use the .ini method is that I want a single line of data for import to Excel, however, I guess one might be able to duplicate that in an .ini file, but then the import to Excel would not work easily, you would have to code an extraction of data to Excel. I'm sure it could also be done, but then we have strayed from the SIMPLE again.
That is how I see it, perhaps though you or someone else could shed light for another method that is as simple or more simple. Keeping in mind that MS Excel is the final tool used for printing the report as preferred by my Management.
Not easy, but I like the idea of doing a live database update that Jens has, I'm just afraid of errors connecting, corruption not caught in time, etc... I might have to try it out some time though on a limited basis in the future.
|
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 878 anonymous users online.
|
|
|