Re: Parsing .CSV files - no luck whatsoever

From: Jerold Schulman (Jerry_at_jsiinc.com)
Date: 03/07/05


Date: Mon, 07 Mar 2005 13:40:57 -0500

On Mon, 07 Mar 2005 10:15:24 -0800, Jason <shift838@y---o.com> wrote:

>As a VBScript newbie I am unable to successfully parse a .CSV plain text
>file using VBScript depite cutting and pasting sample scripts from two
>Microsoft scripting books and one from their Script Repository. It keeps
>throwing "Subscript out of range" errors or empty returns. I've tried using
>a plain text .CSV file from Notepad that looks like this:
>
>test1,test2,test3
>test4,test5,test6
>
>And I've tried exporting event logs as .CSV files. For example, the script
>at this link:
>http://www.microsoft.com/technet/scriptcenter/scripts/logs/text/lgtxvb01.ms
>px
>
>..generates this error "Subscript out of range: '[number: 3]'" when run
>against my Notepad CSV.
>
>What am I missing here? Can all three sample scripts be buggy or should I
>stick to NT shell scripting (which I had no trouble making read a CSV file
>in just a couple of lines)???

I am a newbie VBScripter also.

Use cscript //nolog split.vbs Notepad.csv

where split.vbs contains:
Set objArguments = Wscript.Arguments
iFile=objArguments(0)
set fso = CreateObject("Scripting.FileSystemObject")
set rfile = fso.OpenTextFile(iFile, 1, false)
Do until rFile.AtEndOfStream = True
 iString = rFile.ReadLine
 oString = split(iString, ",")
 Wscript.Echo oString(0)
 Wscript.Echo oString(1)
 Wscript.Echo oString(2)
loop
rFile.close

Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com



Relevant Pages

  • Re: Using a CSV file to Bulk Modify users in AD! HEEELP!
    ... DSRAZOR for Windows does this very well. ... I have often used VB scripts, LDIFDE scripts and CSVDE to automate ... need to modify existing accounts using my data in this CSV file. ...
    (microsoft.public.win2000.active_directory)
  • Re: Script a Bulk Modification of ALL AD users?
    ... I have often used VB scripts, LDIFDE scripts and CSVDE to automate various ... spreadsheet reflects LDAP names, but the friendly names of these LDAP ... but only for creating new accounts. ... need to modify existing accounts using my data in this CSV file. ...
    (microsoft.public.windows.server.active_directory)
  • Re: Script a Bulk Modification of ALL AD users?
    ... I have often used VB scripts, LDIFDE scripts and CSVDE to automate ... trying to work out how to use this CSV file in a script to rapidly ...
    (microsoft.public.windows.server.active_directory)
  • Re: CSVDE Password Limitations - [WP]
    ... I am importing users into AD from CSV file and ran into password assigning ... ' delimited by a quote followed by a comma. ... If you want to stay away from scripts, I believe Joe Richards' free ADMod ...
    (microsoft.public.windows.server.active_directory)
  • Parsing .CSV files - no luck whatsoever
    ... As a VBScript newbie I am unable to successfully parse a .CSV plain text ... Can all three sample scripts be buggy or should I ...
    (microsoft.public.scripting.vbscript)