>>>>Are the first row elements are reliable indicators of the rest of the data?
>>>>
>>>>You could test the first row to discern column types, then use a
replace all or an
update> to convert.
>>>
>>>In a word- No, sir.
>>>
>>>All you know of the data that you are getting, is:
>>>
>>>It´s a bunch of strings in a CSV file, i.e "2000","12345","91.21" asoasf.
>>>There is quite bit more to it, but nothing concerning the issue at hand.
>>
>>oReg=CreateObj('VBScript.RegExp')
>>oReg.Global = .T.
>>oReg.Pattern = '("\d*)(\d{2}")'
>>cFileContent = FILETOSTR(cFileNameToImport)
>>cFileFixed = oReg.Replace(cFileContent,'$1.$2')
>>=STRTOFILE(cFileFixed,cFileNameToImport+'.fixed')
>>
>>Now everything is already converted to exactly the correct decimals. The output for your sample line is:
>>
>>"20.00","123.45","91.21"
>>
>>Just import your CSV. I suspect that you really need to rip off the quotes surrounding numbers, so I'd do:
>>
>>oReg=CreateObj('VBScript.RegExp')
>>oReg.Global = .T.
>>oReg.Pattern = '("\d*)(\d{2}")'
>>cFileContent = FILETOSTR(cFileNameToImport)
>>cFixedUpIntegers = oReg.Replace(cFileContent,'$1.$2')
>>oReg.Pattern = '"(\d*\.\d*)"'
>>cAndRippedAwayUnwantedQuotes = oReg.Replace(cFixedUpIntegers,'$1')
>>=STRTOFILE(cAndRippedAwayUnwantedQuotes,cFileNameToImport+'.fixed')
>>
>>That produces:
>>
>>20.00,123.45,91.21
>>
>>If I try the string "2000","99 and 44/100ths","12345","ABCDGoldFish","91.21"
>>
>>It produces:
>>
>>20.00,"99 and 44/100ths",123.45,"ABCDGoldFish",91.21
>>
>>It requires the WSH; see my sig block for details on the WSH. Do what you like; the WSH is non-negotiable; if you want to use this approach, you need it.
>
>
>Ed,
>
>I´ve tried it, and it´s fast enough, thats for sure.
>
>As I wrote earlier,there is quite bit more to it...
>For reasons better not talked about, I have to step through the file SUBSTR() by SUBSTR() in order to read the values between the commas, all in quotes.
>I then have to look up the SAS INFORMAT (16.3,16.5,13.3 a.s.o. if you are familiar with SAS) in a table, and mimick the behaviour of SAS.
>16.3 seems to mean divide by 100, if it´s not already a decimal value, 16.5 indicates a division by 10000, which would apply to nanoseconds for instance.
>
>I guess what I´m trying to get at here is, I sort of need something like
>
>
>DO CASE
>>>CASE cFormat="16.3"
>>>>>oReg.Pattern ='("\d*)(\d{2}")'
>>>>>lcReplacePattern='$1.$2'
>
>>>CASE cFormat="16.5"
>>>>>oReg.Pattern =????
>>>>>lcReplacePattern=?????
>ENDCASE
>oReg.Replace(cVar,lcReplacePattern)
>
>Where do I find info on the Pattern property? How does it work for a division by 1000,10000?
>
>And finally why does my text show up in bold, ´cause I don´t mean to shout.
>
>Thank you for taking the trouble.
The text is bold because there's an open BOLD tag at the top of this page. I'm putting in a End Bold tag now and now the text is back to normal.
Bye
Liam
Liam O'Hagan
MCP VFP Desktop Apps