Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unicode CSV file fails to reveal data with FILETOSTR() Help

Status
Not open for further replies.

dkean4

Programmer
Feb 15, 2015
282
US
Hi guys...

I am getting unicode CSV files from an application and the FILETOSTR() function takes a 13 meg file to 3 characters

_cliptext = FILETOSTR("F:\VFP Projects\FUN\.UK100CashM15.csv")

How can I convert unicode files to ANSI whatever format will work in VFP?

TIA



Dennis Kean

Simplicity is the extreme degree of sophistication.
Leonardo da Vinci
 
FILETOSTR() result will be fine, the only reason I see causing a problem is using _cliptext.

VFP strings can take 13meg no problem and also can contain any byte. Not every byte will be "printable", but you get the full file content, no matter whether it is ansi, unicode, binary, anything.

When you put something into _cliptext CHR(0) might cause to end this and when you paste the _cliptext you only get 3 characters, but that's not the influence of FILETOSTR(), it is _cliptext doing that.

I haven't tried this, but I am very sure lcFile = FILETOSTR("F:\VFP Projects\FUN\.UK100CashM15.csv") will work out. Look at LEN(lcFile).

Bye, Olaf.

 
Thanks for the quick response, Olaf,

You were correct, I just used that to test it in command. But I do get the following problem if I operate on the string of the unicode file.

STRTRAN(la,",",", ")
lb = STRTRAN(la,",",", ")
STRTOFILE(lb,"F:\VFP Projects\Trading\MT5\.UK100CashM15_.csv")


Here is the result:
2017.05.11 09:00‬㜀㌀㜀㐀⸀㔀    Ⰰ 7377.50000‬㜀㌀㜀㄀⸀     Ⰰ 7373.50000‬㄀㠀㐀Ⰰ 0
2017.05.11 09:15‬㜀㌀㜀㌀⸀㔀    Ⰰ 7377.50000‬㜀㌀㜀㈀⸀     Ⰰ 7374.50000‬㄀ ㈀Ⰰ 0
2017.05.11 09:30‬㜀㌀㜀㔀⸀     Ⰰ 7378.50000‬㜀㌀㜀㔀⸀     Ⰰ 7378.00000‬㤀㘀Ⰰ 0
2017.05.11 09:45‬㜀㌀㜀㜀⸀㔀    Ⰰ 7378.50000‬㜀㌀㜀㄀⸀     Ⰰ 7373.00000‬㄀㜀 Ⰰ 0
2017.05.11 10:00‬㜀㌀㜀㐀⸀㔀    Ⰰ 7384.50000‬㜀㌀㘀㘀⸀     Ⰰ 7377.00000‬㄀㠀㄀㔀Ⰰ 0
2017.05.11 10:15‬㜀㌀㜀㜀⸀     Ⰰ 7387.50000‬㜀㌀㜀㘀⸀     Ⰰ 7385.00000‬㤀㈀㠀Ⰰ 0



And it kills two columns out of 5:

Dennis

Dennis Kean

Simplicity is the extreme degree of sophistication.
Leonardo da Vinci
 
Well, as you say this is Unicode and you can't display Unicode in VFP, there also is no conversion for most bytes looking like gibberish when displayed with their ANSI character, even more so because the string would only be 1/2 as wide in real unicode font display.

The closest you will get is by converting lcFile after FILETOSTR via STRTRAN(lcFile,6). 6 means Unicode to DBCS, which is fine. Don't get the idea you need a second STRCONV with 2=DBCS to single byte. Don't ask why.

Bye, Olaf.


 
Anyway, to precess this data, find something else, you won't be able to process unicode in VFP, even if you would make use of ATC(),SUBSTRC() and all the other string functions for double byte characters.

Unicode should stay unicode, and C# would be fine for processing such data, for example.

Bye, Olaf.
 
Olaf,

You must have had some other function in mind... STRTRAN(lcFile,6) Generates an error.



Dennis Kean

Simplicity is the extreme degree of sophistication.
Leonardo da Vinci
 
I see you meant STRCONV(lcFil,e,6)


Thanks Olaf!

Dennis Kean

Simplicity is the extreme degree of sophistication.
Leonardo da Vinci
 
nigelgomm,

Thanks Nigelgom... my mistake. I don't know where that "e," came from.... Tested it and it works fine...

Dennis Kean

Simplicity is the extreme degree of sophistication.
Leonardo da Vinci
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top