Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem Characters in CSV File
Message
From
16/11/2003 18:11:45
Stuart Ramsey
Medical Business Systems
East Gosford, Australia
 
 
To
15/11/2003 07:45:44
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00850208
Message ID:
00850503
Views:
17
Hi,
Found this bit of code on MS Web Site, it works, I think files were to big for the other method.

PARAMETER file1,file2

PRIVATE fhandle_in, fhandle_out, fisize,inchar

fhandle_in=FOPEN(file1,2)
IF (fhandle_in#-1) && open read/write buffered
fhandle_out=FCREATE(file2) && default read/write
fisize=FSEEK(fhandle_in,0,2) && get the size of the file
=FSEEK(fhandle_in,0,0) && reposition pointer to beginning of
&& file
x=1
DO WHILE (x<=fisize) && process the whole file
inchar=FREAD(fhandle_in,1) && read 1 byte at a time
IF ((inchar = CHR(12)) .OR. ;
(inchar = CHR(00)))

*** change the replacement character '$$'
*** by changing the CHR value below
=FWRITE(fhandle_out,CHR(32)) && replace crlf with $$
ELSE
=FWRITE(fhandle_out,inchar) && write the character to file
ENDIF
x=x+1 && increment the variable
ENDDO
=FCLOSE(fhandle_in) && release the file handle to close
&& file1
=FCLOSE(fhandle_out) && release the file handle to close
&& file2
MODIFY FILE &file2 && opens the target file for viewing
ELSE
RETURN .F. && could not open the input file
ENDIF



Regards
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform