Author: Joe Yoder
Posted: 2015-04-14 01:42:22 Link
When I browse a table from a database with some user defined field names in
it I see long meaningful field names as headers but when I copy to file as
type CSV I get 10 character gobletty goop for field headers.
Is there a built in way to have VFP copy to a CSV file using the field
captions from the dictionary for field headers? If not - how do I
programatically access the captions to write my own?
Thanks in advance,
Joe
--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/CABQeDnW7Tmzw==6GsnSgrHp645oe+25objFjm6qawn-KF6vJGQ@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Author: Gérard LOCHON
Posted: 2015-04-14 02:13:53 Link
Hello.
A table cannot have more than 10 chars as field name, out of a database.
But ... cursors can !
So, if you first make a select from your table into a cursor, and then copy it to a csv file, you'll get your > 10 char field names.
Gérard.
> Message du 14/04/15 08:42
> De : "Joe Yoder"
> A : profoxtech@leafe.com
> Copie à :
> Objet : Creating SDF files with the database caption as header names
>
> When I browse a table from a database with some user defined field names in
> it I see long meaningful field names as headers but when I copy to file as
> type CSV I get 10 character gobletty goop for field headers.
>
> Is there a built in way to have VFP copy to a CSV file using the field
> captions from the dictionary for field headers? If not - how do I
> programatically access the captions to write my own?
>
> Thanks in advance,
>
> Joe
>
>
> --- StripMime Report -- processed MIME parts ---
> multipart/alternative
> text/plain (text body -- kept)
> text/html
> ---
>
[excessive quoting removed by server]
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/970452004.3970.1428995633606.JavaMail.www@wwinf1k29
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Author: Michael Madigan
Posted: 2015-04-14 02:22:19 Link
One way would be to then copy the csv to a memo field, replace the first line with the field names you want, then "copy memo" memo field back to a csv file
the first like would be something like '"header i","header2","header3" '
or
You can use low level file manipulation to delete the first line and replace it with your custom line.
I think this will work.
From: Joe Yoder <joe@wheypower.com>
To: profoxtech@leafe.com
Sent: Tuesday, April 14, 2015 2:42 AM
Subject: Creating SDF files with the database caption as header names
When I browse a table from a database with some user defined field names in
it I see long meaningful field names as headers but when I copy to file as
type CSV I get 10 character gobletty goop for field headers.
Is there a built in way to have VFP copy to a CSV file using the field
captions from the dictionary for field headers? If not - how do I
programatically access the captions to write my own?
Thanks in advance,
Joe
--- StripMime Report -- processed MIME parts ---
multipart/alternative
text/plain (text body -- kept)
text/html
---
[excessive quoting removed by server]
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/804755022.3023460.1428996139095.JavaMail.yahoo@mail.yahoo.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Author: Dave Crozier
Posted: 2015-04-14 02:27:20 Link
As Gerard says, select your data into a cursor with named fields:
Select all <field1> as <Name1>,
<field2> as <Name2> ....
>From <table> into cursor <cursor>
Where <where>
Select <cursor>
Copy to <output> type CSV
Dave
-----Original Message-----
From: ProFox [mailto:profox-bounces@leafe.com] On Behalf Of Joe Yoder
Sent: 14 April 2015 07:42
To: profoxtech@leafe.com
Subject: Creating SDF files with the database caption as header names
When I browse a table from a database with some user defined field names in it I see long meaningful field names as headers but when I copy to file as type CSV I get 10 character gobletty goop for field headers.
Is there a built in way to have VFP copy to a CSV file using the field captions from the dictionary for field headers? If not - how do I programatically access the captions to write my own?
Thanks in advance,
Joe
--- StripMime Report -- processed MIME parts --- multipart/alternative
text/plain (text body -- kept)
text/html
---
[excessive quoting removed by server]
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/18725B8CD2D5D247873A2BAF401D4AB246AE699B@EX2010-A-FPL.FPL.LOCAL
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Author: Paul Newton
Posted: 2015-04-14 02:39:11 Link
That's all very well but I thought he wanted long, meaningful headers like "Home telephone"? In which case some post hoc tinkering with the file would be necessary ...
Paul Newton
-----Original Message-----
From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Dave Crozier
Sent: 14 April 2015 08:27
To: profoxtech@leafe.com
Subject: RE: Creating SDF files with the database caption as header names
As Gerard says, select your data into a cursor with named fields:
Select all <field1> as <Name1>,
<field2> as <Name2> ....
>From <table> into cursor <cursor>
Where <where>
Select <cursor>
Copy to <output> type CSV
Dave
-----Original Message-----
From: ProFox [mailto:profox-bounces@leafe.com] On Behalf Of Joe Yoder
Sent: 14 April 2015 07:42
To: profoxtech@leafe.com
Subject: Creating SDF files with the database caption as header names
When I browse a table from a database with some user defined field names in it I see long meaningful field names as headers but when I copy to file as type CSV I get 10 character gobletty goop for field headers.
Is there a built in way to have VFP copy to a CSV file using the field captions from the dictionary for field headers? If not - how do I programatically access the captions to write my own?
Thanks in advance,
Joe
--- StripMime Report -- processed MIME parts --- multipart/alternative
text/plain (text body -- kept)
text/html
---
[excessive quoting removed by server]
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/9A8106AFB0EF9B44B69045C4448935A284281D4A@NLBAWEXMBX1.infor.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Author: Alan Bourke
Posted: 2015-04-14 03:39:40 Link
You'd have to roll your own.
use mytable
Set textmerge on noshow
set textmerge to myfile.csv
lnFields = Fcount("mytable")
For x = 1 to lnFields
\\<<Field(x, "mytable", 1)>><<iif(x<lnFields, ",", "")>>
Endfor
scan
\\<<field1>>,<<field2>>,<<field3>>
endscan
Set textmerge off
set textmerge to
--
Alan Bourke
alanpbourke (at) fastmail (dot) fm
On Tue, 14 Apr 2015, at 07:42 AM, Joe Yoder wrote:
> When I browse a table from a database with some user defined field names
> in
> it I see long meaningful field names as headers but when I copy to file
> as
> type CSV I get 10 character gobletty goop for field headers.
>
> Is there a built in way to have VFP copy to a CSV file using the field
> captions from the dictionary for field headers? If not - how do I
> programatically access the captions to write my own?
>
> Thanks in advance,
>
> Joe
>
>
> --- StripMime Report -- processed MIME parts ---
> multipart/alternative
> text/plain (text body -- kept)
> text/html
> ---
>
[excessive quoting removed by server]
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/1429000780.138952.253448833.577E7A77@webmail.messagingengine.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Author: Laurie Alvey
Posted: 2015-04-14 05:20:42 Link
Another issue with CSV files is that dates get mangled. The following code
illustrates this:
CLOSE DATABASES ALL
SET STRICTDATE TO 0
SET CENTURY ON
SET SAFETY OFF
CREATE CURSOR tmp (dated D)
INSERT INTO tmp VALUES ({^1999/10/15})
INSERT INTO tmp VALUES ({^2000/10/15})
INSERT INTO tmp VALUES ({^2001/10/15})
BROWSE NORMAL
COPY TO tmp.csv TYPE CSV
MODIFY FILE tmp.csv NOEDIT
COPY TO tmp.txt DELIMITED
MODIFY FILE tmp.txt NOEDIT
ZAP
APPEND FROM tmp.csv TYPE CSV
BROWSE NORMAL && Incorrect dates
APPEND FROM tmp.txt DELIMITED
BROWSE NORMAL && Last three dates are correct
SET STRICTDATE TO 1
SET SAFETY ON
SET CENTURY ON
Changing STRICTDATE, DATE and CENTURY settings seem to have no effect. It
looks like APPEND FROM *.csv TYPE CSV assumes a two digit year. I always
use DELIMITED for this sort of operation (even though you don't get field
names).
Laurie
On 14 April 2015 at 09:39, Alan Bourke <alanpbourke@fastmail.fm> wrote:
> You'd have to roll your own.
>
> use mytable
> Set textmerge on noshow
> set textmerge to myfile.csv
>
> lnFields = Fcount("mytable")
> For x = 1 to lnFields
> \\<<Field(x, "mytable", 1)>><<iif(x<lnFields, ",", "")>>
> Endfor
>
> scan
> \\<<field1>>,<<field2>>,<<field3>>
> endscan
>
> Set textmerge off
> set textmerge to
>
>
> --
> Alan Bourke
> alanpbourke (at) fastmail (dot) fm
>
> On Tue, 14 Apr 2015, at 07:42 AM, Joe Yoder wrote:
> > When I browse a table from a database with some user defined field names
> > in
> > it I see long meaningful field names as headers but when I copy to file
> > as
> > type CSV I get 10 character gobletty goop for field headers.
> >
> > Is there a built in way to have VFP copy to a CSV file using the field
> > captions from the dictionary for field headers? If not - how do I
> > programatically access the captions to write my own?
> >
> > Thanks in advance,
> >
> > Joe
> >
> >
> > --- StripMime Report -- processed MIME parts ---
> > multipart/alternative
> > text/plain (text body -- kept)
> > text/html
> > ---
> >
[excessive quoting removed by server]
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/CAMvTR9e42_-Kkiv_RA8h3cXEKaJchtRyK7PPyh2E440b25stsA@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Author: Joe Yoder
Posted: 2015-04-14 08:00:41 Link
Laurie,
I don't remember ever running into the issue your code illustrates so
copied it and ran it on my system. All the dates showed up without
error! If I had nothing else to do I could spend a lot of time trying to
duplicate your results but not now,
Thanks for sharing,
Joe
On Tue, Apr 14, 2015 at 6:20 AM, Laurie Alvey <trukker41@gmail.com> wrote:
> Another issue with CSV files is that dates get mangled. The following code
> illustrates this:
>
> CLOSE DATABASES ALL
> SET STRICTDATE TO 0
> SET CENTURY ON
> SET SAFETY OFF
> CREATE CURSOR tmp (dated D)
> INSERT INTO tmp VALUES ({^1999/10/15})
> INSERT INTO tmp VALUES ({^2000/10/15})
> INSERT INTO tmp VALUES ({^2001/10/15})
> BROWSE NORMAL
> COPY TO tmp.csv TYPE CSV
> MODIFY FILE tmp.csv NOEDIT
> COPY TO tmp.txt DELIMITED
> MODIFY FILE tmp.txt NOEDIT
> ZAP
> APPEND FROM tmp.csv TYPE CSV
> BROWSE NORMAL && Incorrect dates
> APPEND FROM tmp.txt DELIMITED
> BROWSE NORMAL && Last three dates are correct
> SET STRICTDATE TO 1
> SET SAFETY ON
> SET CENTURY ON
>
> Changing STRICTDATE, DATE and CENTURY settings seem to have no effect. It
> looks like APPEND FROM *.csv TYPE CSV assumes a two digit year. I always
> use DELIMITED for this sort of operation (even though you don't get field
> names).
>
> Laurie
>
> On 14 April 2015 at 09:39, Alan Bourke <alanpbourke@fastmail.fm> wrote:
>
> > You'd have to roll your own.
> >
> > use mytable
> > Set textmerge on noshow
> > set textmerge to myfile.csv
> >
> > lnFields = Fcount("mytable")
> > For x = 1 to lnFields
> > \\<<Field(x, "mytable", 1)>><<iif(x<lnFields, ",", "")>>
> > Endfor
> >
> > scan
> > \\<<field1>>,<<field2>>,<<field3>>
> > endscan
> >
> > Set textmerge off
> > set textmerge to
> >
> >
> > --
> > Alan Bourke
> > alanpbourke (at) fastmail (dot) fm
> >
> > On Tue, 14 Apr 2015, at 07:42 AM, Joe Yoder wrote:
> > > When I browse a table from a database with some user defined field
> names
> > > in
> > > it I see long meaningful field names as headers but when I copy to file
> > > as
> > > type CSV I get 10 character gobletty goop for field headers.
> > >
> > > Is there a built in way to have VFP copy to a CSV file using the field
> > > captions from the dictionary for field headers? If not - how do I
> > > programatically access the captions to write my own?
> > >
> > > Thanks in advance,
> > >
> > > Joe
> > >
> > >
> > > --- StripMime Report -- processed MIME parts ---
> > > multipart/alternative
> > > text/plain (text body -- kept)
> > > text/html
> > > ---
> > >
[excessive quoting removed by server]
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/CABQeDnUwdeVGZzhtAkbDyp5rXsMx8YFLcBopDkb5KrYkTRE4bQ@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Author: Joe Yoder
Posted: 2015-04-14 09:16:11 Link
Thanks Gérard,
I was not aware that a cursor could handle long file names or that a Select
* from sourcefile would give me the file in a cursor with the long file
names. I thought this is great but then I discovered that copy to outfile
type csv gives me the headers in the 10 character format.
Perhaps there is a work around?
Thanks again,
Joe
On Tue, Apr 14, 2015 at 3:13 AM, Gérard LOCHON <g-lochon@wanadoo.fr> wrote:
> Hello.
>
>
>
> A table cannot have more than 10 chars as field name, out of a database.
>
>
>
> But ... cursors can !
>
>
>
> So, if you first make a select from your table into a cursor, and then
> copy it to a csv file, you'll get your > 10 char field names.
>
>
>
> Gérard.
>
>
>
>
>
>
>
>
>
> > Message du 14/04/15 08:42
> > De : "Joe Yoder"
> > A : profoxtech@leafe.com
> > Copie à :
> > Objet : Creating SDF files with the database caption as header names
> >
> > When I browse a table from a database with some user defined field names
> in
> > it I see long meaningful field names as headers but when I copy to file
> as
> > type CSV I get 10 character gobletty goop for field headers.
> >
> > Is there a built in way to have VFP copy to a CSV file using the field
> > captions from the dictionary for field headers? If not - how do I
> > programatically access the captions to write my own?
> >
> > Thanks in advance,
> >
> > Joe
> >
> >
> > --- StripMime Report -- processed MIME parts ---
> > multipart/alternative
> > text/plain (text body -- kept)
> > text/html
> > ---
> >
[excessive quoting removed by server]
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/CABQeDnWPB8esM20_DGoc8kWL3v1Wp6sgFyoARHo16CNF7JCYRA@mail.gmail.com
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
Author: Gene Wirchenko
Posted: 2015-04-14 12:33:33 Link
At 03:20 2015-04-14, Laurie Alvey <trukker41@gmail.com> wrote:
>Another issue with CSV files is that dates get mangled. The following code
>illustrates this:
I tried it. Both sets of dates were correct.
[snip]
Sincerely,
Gene Wirchenko
_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/
** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.