Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Removing / from dates and - from sorts...
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00488037
Message ID:
00488063
Views:
10
>Any ideas brethren?
>
>I am appending a CSV file into a table in a dbc. The CSV file contains dates in the format 2001/03/23 and sort codes in the format 56-12-09. Is there anything I can do at table or dbc level to remove the /s and the -s as each field is appended?
>
>What I am after is 20010323 for the date and 561209 for the sort code...

Got access to the Windows Script Host? If so consider:
oRE = CREATEOBJECT("VBScript.RegExp")
* lcfile is the CSV file
lcstring = FILETOSTR(lcfile)
* Remove the /
oRE.Pattern = "(\d+)\/(\d+)\/(\d+)"
oRE.Global = .T.
lcstring = oRE.Replace(lcstring, "$1$2$3")
oRE.Pattern = "(\d+)\-(\d+)\-(\d+)"
lcstring = oRE.Replace(lcstring, "$1$2$3")
and save the string back using STRTOFILE().

Now admittedly, CHRTRAN() could do the same thing, but if there are any slashes or hyphens that need to be retained, they would be changed too. With this, they won't be.
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform