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

Txt databse of foxpro 1

Status
Not open for further replies.

mariolucas75

Technical User
Apr 15, 2021
4
GB
Dear Forum,

Would you please be so kind and help me with one question:

I have foxpro database in form of txt file. And as i know some jpg files are somehow stored or embedded in this txt file.... so how can it be done to retrieve jpg files from txt database.... ?

Thank you so much.
Best Regards
 
Hi

Please have a look at the APPEND FROM command in the Help File

APPEND FROM FileName | ?[FIELDS FieldList] [FOR lExpression]

[[TYPE] [DELIMITED [WITH Delimiter | WITH BLANK | WITH TAB

| WITH CHARACTER Delimiter] | DIF | FW2 | MOD | PDOX | RPD |

SDF | SYLK | WK1 | WK3 | WKS | WR1 | WRK | CSV | XLS | XL5

[SHEET cSheetName] | XL8 [SHEET cSheetName]]] [AS nCodePage]

hth

MarK
 
Hello and welcome to the forum.

I have foxpro database in form of txt file.

If your "txt file" is a text file, then the above statement doesn't make sense. A database cannot be "in the form of" a text file. It is possible to take a Foxpro table (which mormally has the extension DBF) and then change the extension to TXT. But doing that doesn't make into a text file. You must still treat it as a Foxpro table.

i know some jpg files are somehow stored or embedded in this txt file.

Again, if this is really a text file, you cannot have images stored in it. This is nothing to do with FoxPro. It is the basic definition of a text fie.

I can only think that you mean that you have a Foxpro table containing images in a General field, and for some reason the table's extension has been changed to TXT. If that's the case, you can use some code similar to the following:

Code:
USE MyTable     && MyTable is your VFP table
COPY TO TempTable FIELDS MyGeneralField NEXT 1  && MyGeneralField is the name of the General field
lcStr=FILETOSTR("TempTable.fpt")
lcImage = RIGHT(lcStr,LEN(lcStr) - 599)
STRTOFILE(lcImage, "MyImage.bmp")  && change MyImage.bmp to where you want to save the file

If I have misunderstood what you are asking, please clarify.

Mike






__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mark

Are you thinking the OP is trying to import the text file into a DBF?



Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Dear forum members that you very much for your quick response.

Mike Lewis yes ... your assumption is absolutely correct and i apologies for being not precise coz i am absolutely new to databases and foxpro.
Would you kindly advise me which version or software to install to use code that you specified... ?

Thank you so much
 
Mike's code will generally work with VFP5-9
It will most likely only extract .bmp files though perhaps not .jpg ones
the -599 covers an offset for .bmp files which would most likely be different.

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
GriffMG,

"the -599 covers an offset for .bmp files which would most likely be different" what does this offset mean ?
Will it extract jpgs from txt file ?

 
I am not sure about jpg files, bmp files are a 'known quantity' and are reliably extracted from a VFP memo file
using the method above. Each general field has a 'prefix' or 'offset' that is to do with the software that
was applicable on the workstation that was in use when the file was appended - at least that is what I believe.

The length of that prefix is 599 characters for all bmp files that I have come across, on my PC I just imported
a jpg and the offset was 701 characters in length, but there were also a couple of hundred characters on the end too!
In fact the offset included the name and location of the original file (more than once), so could be variable.

**tested** it is

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Hi Mario.
If your file does not contain sensitive data than zip the file and upload here so we can inspect and see what can be done with it. ost probably you will have 2 files: one with extension DBF and and one with extension FPT . They belong together and cannot be used by itself, always together.
Stay healthy,
Koen


P.S.
If your file contains littlebit sensitive date but sensitive enough not to publish here on this forum, you are invited to call me I can try to see what I can do for you.
Pictures in a .DBF file is not usual, but can be done.

P.P.S Take care: my Whatsapp extension will be removed from this forum in 1 hour.
 
@Koen

TBK files - I think you mean .FPT

Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Dear All,

Thank you so much for your assistance.... all of yours advices are very interesting and helpful.
Sorry asking the same question (which sounds silly i guess ) ... if jpg or bmp info is "included" in txt file .... what is the use of dbf and fpt files? Would not you need in this case three of them txt dbf fpt ?

Thks so much
 
Mario, it's not a stupid question. But you do need to understand the difference between the different types of files.

First, a FoxPro table (what you have been referring to as a database) consists of one, two or three files. One of them is always a DBF file. Then there might be an index file, which is a CDX. And there might be a file to hold memo fields as well as images and certain other "objects"; that is a FPT. If you have embedded images, then the FPT must be present. These files always go together. If the CDX or FTP exists, it must be present in order to open the table.

A TXT file is quite different. This is a plain text file. It has nothing to do with databases or tables. It can only hold text, never images.

It is not at all clear to us what kind of files you have or what they contain. That's why we suggested that you upload them to the forum so that we can examine them. (But don't do that if they contain private or confidential information.)

In the case of the TXT file, if you can open it in a text editor, such as Notepad, you could try copying the text and pasting it into a forum message. But if it is more than, say, a dozen or so lines of text, don't paste the whole thing - just a representative sample.

I hope this helps.

CORRECTION: For FTP, read FPT. Now corrected (and thanks to Griff for pointing it out).

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Well, let me add one observaton: If you only have one txt file, it won't contain images.

It ither is really a text file, just text, pehaps a comma separated valus (CSV file) you could convert or append to a table.
If - as Mike assumes - it's a DBF with a renamed extension, it'll onl be th DBF and you're missing the other files, especially the one which originally had the FPT extension, where any longer values or objects are stored, images, for example.

If someone exported a DBF that contained images to a TXT file any memo, general, blob, or other field types possible containing images is NOT exported to that txt file and so that doesn't come over to you.

So in short: a txt file will never contain images, no matter whether it is created by an EXPORT or CSV file creation or whether it is a DBF file with renamed file extension. Then you only have the part of a table that can store intgers, short text fields, dates, datetnmes, etc. but not images.



Chriss
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top