Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


.CSV to text

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> .CSV to text
  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 >>
 .CSV to text - 7/21/2008 5:33:48 AM   
  foster.craig.d

 

Posts: 2
Score: 0
Joined: 7/18/2008
Status: offline
Hello,

I've been beating my head against a wall for quite sometime now. I need a script that will read in a .CSV file, and find where the first column value is zero. Once that point is established a text file
that contains the next 500 rows of the first column and the next column needs to be written. This will be repeated, for the remaining columns. That is column one and whichever column is the next, with a seperate file for each pair.

Problem is finding where this value of zero occurs, and identifying the cell location. I've tried many differnt snippets of code found here an there. At this point I'm thoroughly confused. I tried
to do this initially with AWK, it seems AWK doesn't behave as expected through the command prompt. So now I've resorted to VBScript, however this is relatively new and of course it doesn't seem
to behave as expected either.

I did try the macro recorder method as suggested on this forum. The latest bit of code snippet I've tried is coming from the Sam's 21 day book, and combined with a snippet out of
the Visual Basic reference.

Thank you in advance for any help that may be forthcoming.

The snippet that I am currently working with is as follows:

Dim appXL

Set appXL = WScript.CreateObject("Excel.Application")
'Set appWS = WScript.CreateObject("Excel.Worksheet")
'Set appRG = WScript.CreateObject("Excel.Range")
appXL.Visible = True

appXL.Workbooks.Open("C:\P1_2_4ms.CSV")

MsgBox(appXL.Windows(1).Caption)

MsgBox(appXL.Cells(1, 3).Value)

With ActiveSheet(1)appXL.Cells("a1:a500")
  Set c = appXL.Find(0,  lookin:=xlValues)
   If Not c Is Nothing Then
       firstAddress = c.Address
       Do
           c.Value = 5
           Set c = .FindNext(c)
       Loop While Not c Is Nothing And c.Address <> firstAddress
   End If
End With



If appXL.ActiveWorkbook.Saved = False Then
   MsgBox("Save me")
End If
 
 
Post #: 1
 
 RE: .CSV to text - 7/24/2008 7:31:17 AM   
  mcds99


Posts: 434
Score: 4
Joined: 2/28/2006
Status: offline
Excel has specific needs when using it for data.

Take a look at this code to see what you can get from it.


      

_____________________________

Sam

Keep it Simple Make it Fun KiSMiF

(in reply to foster.craig.d)
 
 
Post #: 2
 
 
 
  

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 >> .CSV to text 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