Dohko


Hi

I would like to know how can I add some text to an exported file from Fox Pro.

For example I have a Database named Sample. With 1 column Named State.

This column contains numbers.

SELECT State, COUNT(*);
FROM sample;
GROUP BY State ;
INTO CURSOR MyCount
COPY TO temp.txt DELIMITED

Using this code gives me txt file with the numbers and the frequencies. Is there any way I can introduce text into the exported file

Right now my output is something like this

1,22

2,5

3,7

4,8

Any way to do it like

STATE COUNT

1 22

2 5

And so on

Thanks




Re: Exporting Data to Text File

Naomi Nosonovsky


You may use

COPY TO temp.txt TYPE CSV

This will add field names to your text file and you also can open this file with Excel.

You also can add captions with

lcHeader = [State Count]

strtofile(m.lcHeader + chr(13) + chr(10) + filetostr('temp.txt'), 'MyOutput.txt')






Re: Exporting Data to Text File

Alex Feldstein

As always in VFP, there are many ways.

You could:

  • Use the report writer to create a report format the way you like it and "print" to a txt file
  • Use Low Level functions instead of COPY TO
  • Use a formatted table, adding the headers and use STRTOFILE() to export to text
  • Use what you have now and open the resulting text file (with LLF), edit it and save it back as text

In this case I would probably use the report writer to create a simple FRX file and then do a REPORT FORM...TO PRINT

(you can get much fancier than that with VFP 9's report writer if you want).






Re: Exporting Data to Text File

CetinBasoz

Follow Alex's advices. But first ask yourself what would you do with such a file If there is a reason then you might as well use:

set headings on

list to file myFile.txt off noconsole





Re: Exporting Data to Text File

Dohko

Okay I will try that.

I'm trying to learn how to use Fox Pro. Just started this week.

Any Online tutorials you can recommend





Re: Exporting Data to Text File

Alex Feldstein

Dohko wrote:
I'm trying to learn how to use Fox Pro. Just started this week.

Any Online tutorials you can recommend

You just asked that question and was answered in your other thread:

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1726896&SiteID=1