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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSV file Manipulation

Status
Not open for further replies.

gcw1

Programmer
Jan 12, 2002
204
CA
Hi, is it possible to manipulate data contained in a .csv file without having to save it as a .dbf file first? Fields in the .csv might be formatted as either text or numeric. Using fp2.6a for windows. Thanks

Glenn
 
First - "Fields in the .csv might be formatted as either text or numeric"

Actually a CSV file is one version of a Text file. Consequently, EVERYTHING in it is a character representation.
Either:
* a character string value
* a character representation of a date
* a character representation of a Boolean (logical) value
* a character representation of a number (but not really)

You can always use FOPEN() with FSEEK(), FGETS() or FREAD() and FPUTS() or FWRITE() to manipulate the data within a file.
It is a slow method, but sometimes it is the best and/or only way.

Good Luck,


JRB-Bldr
VisionQuest Consulting
Business Analyst & CIO Consulting Services
CIOServices@yahoo.com
 
If you invest in a recent version of Visual FoxPro you could use FILETOSTR() and STRTOFILE() to read the file, edit the contents as a string and then rewrite it back. Just another reason get have at least VFP version 6 SP5 or newer sitting on your desktop.

dbMark
 
Fields in the .csv might be formatted as either text or numeric"... Using excel I once tried to format a field to be something other then text and it wouldn't stick... it all makes sense now.

Thanks for the replies. I'll have to play around with the functions you listed and see what I can come up with. Upgrading to VFP would be nice, but we are heading away from the foxpro family and incorporating SQL server and visual basic. For the time being though we still have FP 2.6 in use. Thanks

Glenn
 
SQL Server is a good back-end for a number of reasons, but you can still use Visual Foxpro as an extremely powerful front-end and data processing engine working in conjunction the SQL Server. VFP is MUCH more powerful in many ways than many of the competition (especially VB), just not as widely publicised.

Perhaps you might be able to convince your cohorts to consider using VFP with your SQL Server.

Good Luck,


JRB-Bldr
VisionQuest Consulting
Business Analyst & CIO Consulting Services
CIOServices@yahoo.com
 
Visual FoxPro is highly database-oriented whereas Visual Basic is, well, basic. VFP has built-in commands available that aren't available in VB unless you write them yourself or buy them. What VB does have in its favor is enormous brand recognition: Lots of companies feel that if you don't program in C++ or VB or some other hot language, then it's not mainstream and therefore they're reluctant to invest in it. VFP is not just another niche programming language, but sadly it does have an uphill battle to be recognized for its versatility and wonderful merits.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top