Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


write into the first line of textfile

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,35790
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> write into the first line of textfile
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 write into the first line of textfile - 6/26/2006 7:10:06 PM   
  zurheiden

 

Posts: 2
Score: 0
Joined: 6/26/2006
Status: offline
Hello,

i have made a data base export into the file test.csv (lies on C:\Ablage\test.csv). Now i have to write on a Windows-XP-Client into the first line of test.csv the field-designators with VBS, because the export program (Commence) cannot do this unfortunately and i need it for the import.

How looks the VBS-Code for this (I work mainly with PHP and know therefore VBS only little from earlier ASP projects)?

Sorry for my bad english.

Greeting Rainer
 
 
Post #: 1
 
 RE: write into the first line of textfile - 6/26/2006 10:49:04 PM   
  mbouchard


Posts: 1903
Score: 14
Joined: 5/15/2003
From: USA
Status: offline
Hmm, I hate when I can find a script.  I believe that I had one that did this, but not sure where it is, so...

To do this:

1) Open the CSV (Use ForReading) and put it into a variable using ReadAll Close CSV.
2) Open the CSV using ForWriting.  Write what you want, then add in the Variable created above.

_____________________________

Mike

For useful Scripting links see the Read Me First stickey!

Always remember Search is your friend.

(in reply to zurheiden)
 
 
Post #: 2
 
 RE: write into the first line of textfile - 6/27/2006 11:12:03 PM   
  zurheiden

 

Posts: 2
Score: 0
Joined: 6/26/2006
Status: offline
Thank you - i have found a solution:

'******************************************************

Dim tb,fso,f1,f2,i,wert,a,leseDatei,CheckStr

Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const TEMPDATEI= "U:\upload\zwischenablage.txt"
Const DATENDATEI01= "U:\upload\teilnehmer.TXT"
Const DATENDATEI02= "U:\upload\vorgang.TXT"

Sub TextfileMod(File,Value)
Set fso = CreateObject("Scripting.FileSystemObject")
set leseDatei = fso.OpenTextFile(File,ForReading)
CheckStr = LEFT(leseDatei.ReadLine,5)
If CheckStr<>"1,2,3" Then
Set f1 = fso.OpenTextFile(TEMPDATEI, ForWriting, True, 0)
wert = "1"
for i = 2 to Value
wert = wert & "," & i
next
f1.Writeline "" & wert
Set f2 = fso.OpenTextFile(File, ForReading)
a = f2.ReadAll
f1.Write a
f1.close
f2.close
fso.CopyFile TEMPDATEI, File, True
End If
end Sub

TextfileMod DATENDATEI01,28
TextfileMod DATENDATEI02,18

'******************************************************

Greetings Zurheiden

(in reply to mbouchard)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> write into the first line of textfile Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts