|
 |
asp_web_howto thread: How to remove last character from text file with asp vbscript?
Message #1 by George Lavrov <glavrov@m...> on Sat, 13 Apr 2002 10:55:44 -0700
|
|
I am exporting table into csv file. Everything is fine except I always have
extra comma at the end of the last line. Since I also need to read this file
with asp and export it into variable I need to get rid of that last comma.
How can I do this?
Thanks in advance
George L.
Message #2 by jwindsor@v... on Sat, 13 Apr 2002 19:09:57
|
|
> I am exporting table into csv file. Everything is fine except I always
have
extra comma at the end of the last line. Since I also need to read this
file
with asp and export it into variable I need to get rid of that last comma.
How can I do this?
Thanks in advance
George L.
Try this....
**********************************************************
dim myCSVfile
myCSVfile = "I need to get rid of the comma at the end,"
myCSVfile = left(myCSVfile,len(myCSVfile)-1)
**********************************************************
Message #3 by George Lavrov <glavrov@m...> on Sat, 13 Apr 2002 11:22:54 -0700
|
|
Cool, that was fast. Thank you. One problem so, I can't figure out how to
place it properly in my code. Here is a snip:
-----------------------------
do while not recordset.eof
strField1 = strField1 & recordset.fields("Field1") & ", "
recordset.movenext
loop
varFilePath2 = "C:\temp\" & Session("UserId") & ".csv"
set objFSO = server.createobject("scripting.filesystemobject")
set objcsvFile = objFSO.createTextFile(varFilePath2, true)
' ****if I try this:
objcsvFile = left(objcsvFile,len(objcsvFile)-1)
'*** I will ado error: Object doesn't support this property or method
objcsvFile.writeline strField1
Set ReadStream = objFSO.OpenTextFile(varFilePath2, 1)
strReadFile = Readstream.ReadAll
---------------
What I am doing wrong?
George L.
-----Original Message-----
From: jwindsor@v... [mailto:jwindsor@v...]
Sent: Saturday, April 13, 2002 12:10 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Re: How to remove last character from text file
with asp vbscript?
> I am exporting table into csv file. Everything is fine except I always
have
extra comma at the end of the last line. Since I also need to read this
file
with asp and export it into variable I need to get rid of that last comma.
How can I do this?
Thanks in advance
George L.
Try this....
**********************************************************
dim myCSVfile
myCSVfile = "I need to get rid of the comma at the end," myCSVfile
left(myCSVfile,len(myCSVfile)-1)
**********************************************************
---
Improve your web design skills with these new books from Glasshaus.
Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20
Message #4 by jwindsor@v... on Sat, 13 Apr 2002 20:02:27
|
|
> Cool, that was fast. Thank you. One problem so, I can't figure out how to
place it properly in my code. Here is a snip:
-----------------------------
do while not recordset.eof
strField1 = strField1 & recordset.fields("Field1") & ", "
recordset.movenext
loop
varFilePath2 = "C:\temp\" & Session("UserId") & ".csv"
set objFSO = server.createobject("scripting.filesystemobject")
set objcsvFile = objFSO.createTextFile(varFilePath2, true)
' ****if I try this:
objcsvFile = left(objcsvFile,len(objcsvFile)-1)
'*** I will ado error: Object doesn't support this property or method
objcsvFile.writeline strField1
Set ReadStream = objFSO.OpenTextFile(varFilePath2, 1)
strReadFile = Readstream.ReadAll
---------------
What I am doing wrong?
George L.
-----Original Message-----
From: jwindsor@v... [mailto:jwindsor@v...]
Sent: Saturday, April 13, 2002 12:10 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Re: How to remove last character from text file
with asp vbscript?
> I am exporting table into csv file. Everything is fine except I always
have
extra comma at the end of the last line. Since I also need to read this
file
with asp and export it into variable I need to get rid of that last comma.
How can I do this?
Thanks in advance
George L.
Try this....
**********************************************************
dim myCSVfile
myCSVfile = "I need to get rid of the comma at the end," myCSVfile
left(myCSVfile,len(myCSVfile)-1)
**********************************************************
---
Improve your web design skills with these new books from Glasshaus.
Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20
You'll need to include the "adovbs.inc" file in your ASP.
Message #5 by George Lavrov <glavrov@m...> on Sat, 13 Apr 2002 12:00:02 -0700
|
|
Figured it out:
objcsvFile.writeline left(strField1,len(strField1)-2)
I forgot about extra space after comma.
Thanks for advise.
George L.
-----Original Message-----
From: jwindsor@v... [mailto:jwindsor@v...]
Sent: Saturday, April 13, 2002 1:02 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Re: How to remove last character from text file
with asp vbscrip t?
> Cool, that was fast. Thank you. One problem so, I can't figure out how
> to
place it properly in my code. Here is a snip:
-----------------------------
do while not recordset.eof
strField1 = strField1 & recordset.fields("Field1") & ", " recordset.movenext
loop
varFilePath2 = "C:\temp\" & Session("UserId") & ".csv"
set objFSO = server.createobject("scripting.filesystemobject")
set objcsvFile = objFSO.createTextFile(varFilePath2, true)
' ****if I try this:
objcsvFile = left(objcsvFile,len(objcsvFile)-1)
'*** I will ado error: Object doesn't support this property or method
objcsvFile.writeline strField1
Set ReadStream = objFSO.OpenTextFile(varFilePath2, 1)
strReadFile = Readstream.ReadAll
---------------
What I am doing wrong?
George L.
-----Original Message-----
From: jwindsor@v... [mailto:jwindsor@v...]
Sent: Saturday, April 13, 2002 12:10 PM
To: ASP Web HowTo
Subject: [asp_web_howto] Re: How to remove last character from text file
with asp vbscript?
> I am exporting table into csv file. Everything is fine except I always
have
extra comma at the end of the last line. Since I also need to read this
file
with asp and export it into variable I need to get rid of that last comma.
How can I do this?
Thanks in advance
George L.
Try this....
**********************************************************
dim myCSVfile
myCSVfile = "I need to get rid of the comma at the end," myCSVfile
left(myCSVfile,len(myCSVfile)-1)
**********************************************************
---
Improve your web design skills with these new books from Glasshaus.
Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20
You'll need to include the "adovbs.inc" file in your ASP.
---
Improve your web design skills with these new books from Glasshaus.
Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20
|
|
 |