Good afternoon,
Am outputing a text file type delimited with character "" character tab, works great. The table it is being generated from is a mix of character and numeric fields...
The only issue I have is that they wnat the fields names to make up the first record. My original throught was to build a separate table with the fields names entered in the record (one record) and then append from my file. This would put the field names up top and the rest of the data after that. Am concerned about adding the previously numeric fields as a character field.
Any suggestions? TIA, Desmond
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html ---
Quick & dirty method. Low level file handling. Write out header directly to a new file, then simply read in all lines from current file and append to new file. That would do it.
Regards, Kurt Wendt Senior Systems Analyst
Tel. +1-212-747-9100 www.GlobeTax.com
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Desmond Lloyd Sent: Monday, June 13, 2016 4:19 PM To: profoxtech@leafe.com Subject: VFP9: Outputing a text file with field names
Good afternoon,
Am outputing a text file type delimited with character "" character tab, works great. The table it is being generated from is a mix of character and numeric fields...
The only issue I have is that they wnat the fields names to make up the first record. My original throught was to build a separate table with the fields names entered in the record (one record) and then append from my file. This would put the field names up top and the rest of the data after that. Am concerned about adding the previously numeric fields as a character field.
Any suggestions? TIA, Desmond
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html ---
[excessive quoting removed by server]
Don't duplicate the (meta)data as data, as that will come back to bite you the first time you add or rename a field, or set a filter on the table data and forget to do the same to the metadata.
There's a couple ways to do this. You could use AFIELDS to get all the fieldnames and then generate a string, or you could hack an existing function to do the list for you...
I did this for a client recently, and ended up doing something like (no errors in Gmail!): #DEFINE COMMA "," #DEFINE SPACE " " #DEFINE CRLF CHR(13)+CHR(10) COPY TO header.csv TYPE CSV WHERE .F. && gets you just a header record COPY TO tempfile.txt DELIMITED WITH "" SEPARATED WITH CRLF string1 = strtran(FileToStr("header.csv"), COMMA, SPACE) string2 = FileToStr("tempfile.txt") output = StrToFile(string1+CRLF+string2, "output.txt")
On Mon, Jun 13, 2016 at 4:18 PM, Desmond Lloyd desmond.lloyd@gmail.com wrote:
Good afternoon,
Am outputing a text file type delimited with character "" character tab, works great. The table it is being generated from is a mix of character and numeric fields...
The only issue I have is that they wnat the fields names to make up the first record. My original throught was to build a separate table with the fields names entered in the record (one record) and then append from my file. This would put the field names up top and the rest of the data after that. Am concerned about adding the previously numeric fields as a character field.
Any suggestions? TIA, Desmond
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html
[excessive quoting removed by server]