Hi,

I need to read in a CSV file with 4 values per line.

value1,value2,value3,value4
value1,value2,value3,value4

and so on....


I need to read that in to some arrays in VBScript. I want to something
similar to this

Set csvFile = objFileSystem.GetFile(csvFilePath)
Set csvFileForRead = csvFile.OpenAsTextStream(ForReading)

count = csvFileForRead.numberOfLines

For i = 0 to count - 1
strLine = csvFileForRead.readLine
value1Array(i) = substring(0,",")
value2Array(i) = substring(first comma, next comma)
and so on
next

I don't want the code to work only with a four value CSV file either...

Can someone suggest a way to implement this?

Thanks.

Also, what I want to do is use the script to load a CSV file of events,
dates, times, and notes into an Outlook calendar on an exchange server
so any insight on that would be welcomed to. In a previous post, a
poster suggested looking at VbaOUTL9.chm but I could not find a copy of
this.

Thanks.

Re: Reading in a line from a CSV by natemrice

natemrice
Thu Nov 09 15:04:14 CST 2006

How about this:

Set csvFile = objFileSystem.GetFile(csvFilePath)
Set csvFileForRead = csvFile.OpenAsTextStream(ForReading)

sFileContents = csvFileForRead.ReadAll

aEachLineInFile = Split(sFileContents, vbCRLF)

For Each sLine in aEachLineInFile
aArrayOfValues = Split(sLine,",")

For Each sValue In aArrayOfValues
'do some stuff

Next
Next

-Nate
http://www.naterice.com

K.J. 44 wrote:
> Hi,
>
> I need to read in a CSV file with 4 values per line.
>
> value1,value2,value3,value4
> value1,value2,value3,value4
>
> and so on....
>
>
> I need to read that in to some arrays in VBScript. I want to something
> similar to this
>
> Set csvFile = objFileSystem.GetFile(csvFilePath)
> Set csvFileForRead = csvFile.OpenAsTextStream(ForReading)
>
> count = csvFileForRead.numberOfLines
>
> For i = 0 to count - 1
> strLine = csvFileForRead.readLine
> value1Array(i) = substring(0,",")
> value2Array(i) = substring(first comma, next comma)
> and so on
> next
>
> I don't want the code to work only with a four value CSV file either...
>
> Can someone suggest a way to implement this?
>
> Thanks.
>
> Also, what I want to do is use the script to load a CSV file of events,
> dates, times, and notes into an Outlook calendar on an exchange server
> so any insight on that would be welcomed to. In a previous post, a
> poster suggested looking at VbaOUTL9.chm but I could not find a copy of
> this.
>
> Thanks.


Re: Reading in a line from a CSV by K

K
Fri Nov 10 12:20:59 CST 2006

I will try that. Thank you very much for your insight.

`
natemrice@gmail.com wrote:
> How about this:
>
> Set csvFile = objFileSystem.GetFile(csvFilePath)
> Set csvFileForRead = csvFile.OpenAsTextStream(ForReading)
>
> sFileContents = csvFileForRead.ReadAll
>
> aEachLineInFile = Split(sFileContents, vbCRLF)
>
> For Each sLine in aEachLineInFile
> aArrayOfValues = Split(sLine,",")
>
> For Each sValue In aArrayOfValues
> 'do some stuff
>
> Next
> Next
>
> -Nate
> http://www.naterice.com
>
> K.J. 44 wrote:
> > Hi,
> >
> > I need to read in a CSV file with 4 values per line.
> >
> > value1,value2,value3,value4
> > value1,value2,value3,value4
> >
> > and so on....
> >
> >
> > I need to read that in to some arrays in VBScript. I want to something
> > similar to this
> >
> > Set csvFile = objFileSystem.GetFile(csvFilePath)
> > Set csvFileForRead = csvFile.OpenAsTextStream(ForReading)
> >
> > count = csvFileForRead.numberOfLines
> >
> > For i = 0 to count - 1
> > strLine = csvFileForRead.readLine
> > value1Array(i) = substring(0,",")
> > value2Array(i) = substring(first comma, next comma)
> > and so on
> > next
> >
> > I don't want the code to work only with a four value CSV file either...
> >
> > Can someone suggest a way to implement this?
> >
> > Thanks.
> >
> > Also, what I want to do is use the script to load a CSV file of events,
> > dates, times, and notes into an Outlook calendar on an exchange server
> > so any insight on that would be welcomed to. In a previous post, a
> > poster suggested looking at VbaOUTL9.chm but I could not find a copy of
> > this.
> >
> > Thanks.