Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. sponsors. rss.
 From: Anders Altberg
  Where is Anders Altberg?
 Uppsala
 Sweden
 Anders Altberg
 To: mike N
  Where is mike N?
 Balt
 Maryland - United States
 mike N
 Tags
Subject: RE: Visual Foxpro .CSV code help needed.
Thread ID: 210129 Message ID: 210136 # Views: 35 # Ratings: 0
Version: Visual FoxPro 9 Category: Microsoft Office Automation
Date: Saturday, January 03, 2009 3:21:29 PM         
   


> Visual Foxpro .CSV code help needed.
> One of sites changes a code value in column B to the same code shared
> by other sites "FDC" but has a differnt code value in column C than the others.
> In order for my code to run I need that value changed back from "FDC" to the old code "IDC"
>
> So if column A="0125" and column B = "FDC" change column B value to "IDC"
>
>
> My .csv file looks like this
>
> A B C D
> 0025 FAD 25
> 0120 F20 32
> 0025 FAD 25
> 0125 FDC 48
> 0401 FDC 26
> 0401 FDC 26
> 0125 FDC 48
> 0120 F20 32
> 0025 FAD 25
> 0125 FDC 48
> 0125 QTT 10
> 0125 QTT 10
>
>
> My results should look like this
>
> A B C D
> 0025 FAD 25
> 0120 F20 32
> 0025 FAD 25
> 0125 IDC 48
> 0401 FDC 26
> 0401 FDC 26
> 0125 IDC 48
> 0120 F20 32
> 0025 FAD 25
> 0125 IDC 48
> 0125 QTT 10
> 0125 QTT 10
>
> My .csv file changes name weeky my vfp program find the file with the gretest date
> value and opens it already. I need to run the code to change the column B values
> and continue to run my current vfp program.
>
> I have the vba I am pretty sure will work could use some help in the translation.
>
> Sub ok()
> Dim a As Range
> Dim rng As Range
>
> Set rng = Range(Cells(1, 1), Cells(Rows.Count, 1).End(xlUp))
> For Each a In rng
> If a.Value = "0125" And a.Offset(0, 1).Value = "FDC" Then
> a.Offset(0, 1).Value = "IDC"
> End If
> Next
> End Sub
>
> Thank you, Thank you



USE Mytable 
 APPEND FROM textfile TYPE CSV 
 UPDATE Mytable SET columnb = 'IDC' WHERE columna = '0125' AND columnb='FDC'


TYPE CSV is used in VFP only for textfiles whose top row contains column names, while data begins in row2. This top row is not included in the append.
If the data starts in row1 then use APPEND FROM textfile TYPE DELIMITED
BTW, CSV means Comma-Separated Values. Your sample is not comma separated.
-Anders



COMPLETE THREAD
Visual Foxpro .CSV code help needed. Posted by mike N @ 1/3/2009 2:35:59 PM
RE: Visual Foxpro .CSV code help needed. Posted by Anders Altberg @ 1/3/2009 3:21:29 PM
RE: Visual Foxpro .CSV code help needed. Posted by Cetin Basoz @ 1/3/2009 3:33:23 PM
RE: Visual Foxpro .CSV code help needed. Posted by mike N @ 1/3/2009 4:37:31 PM
RE: Visual Foxpro .CSV code help needed. Posted by mike N @ 1/3/2009 4:41:39 PM
RE: Visual Foxpro .CSV code help needed. Posted by Cetin Basoz @ 1/3/2009 5:22:19 PM
RE: Visual Foxpro .CSV code help needed. Posted by mike N @ 1/3/2009 8:02:06 PM
RE: Visual Foxpro .CSV code help needed. Posted by Anders Altberg @ 1/3/2009 8:22:47 PM
RE: Visual Foxpro .CSV code help needed. Posted by Cetin Basoz @ 1/3/2009 10:08:08 PM
RE: Visual Foxpro .CSV code help needed. Posted by mike N @ 1/7/2009 8:57:19 PM
RE: Visual Foxpro .CSV code help needed. Posted by Cetin Basoz @ 1/8/2009 1:52:17 AM
RE: Visual Foxpro .CSV code help needed. Posted by tushar @ 1/3/2009 4:59:49 PM