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

Convert a text file to dbf

Status
Not open for further replies.

VCat88

Programmer
Oct 11, 2002
57
0
0
MY
I would like to convert a text file that is space delimeted into dbf. can anyone show me a simple code how to do this thanks!!!
 
My Current Practice:-
Open Excel Files.
Alt+ F (File) ->Open -> Change File Of Type to 'text' .txt
Then -> select the text files to open.

Choose Delimited.
Start import at row 2. (Row 1 is header format)
File Origin: 437 OEM United States.
Click Next>
Choose Tab,SemiColon,Comma and Space.
Then Click Next.
Column Data Format: Do not import column (Skip)
Click Finished.

Adjusted the column width.
Alt+F (File) --> Save as
Change File Type: Microsoft Excel 5.0/95 Workbook (.xls)
Save.
Example Filename save as ABC.xls
Then close the Excel Documents.


Then at Visual FoxPRo TYPE COMMAND :-
Import From ABC xls
BROWSE
then the data succesfully Import

SO --> I hope can simplify the steps above.
Any suggestion?
Some more I need manually Change the data structure of the table import to follow the first row. (Ignore imported first row data (start at row 2, since is not a data previously.)



 
After you open the file in Excel and alter it, When you save the file in Excel, Why don't you save it as a *.DBF.



David W. Grewe Dave
 
Mike's suggestions are the best.

But if you want to use Excel.....
Some 'tricks' about saving an Excel file as a DBF.

1. Make your top row, a row of field names (limited to 10 characters with no spaces).
2. Highlight/Select all rows & columns that you want to export, but NO other rows or columns.
3. Make each Text column slightly wider than Auto-fit makes it, so as to prevent en-expected field value truncation
4. Even though Excel column data is set as Text, if the data appears like numbers, Excel will export it as numbers.
If you want that column to be characters, insert a row below the top (field name) row and insert a character above the numbers. This 'dummy' row can be deleted later.
5. Remember that Excel is limited in the number of rows that it can handle. If your text file is too large, Excel will chop off the rows that it cannot handle.
6. Also note that the steps that you currently use above can all be automated as a process within VFP.

You do not tell us if this is a one-time import or if this has to be done repeatly.
If one-time any of these suggestions will work.
If repeatedly, then you may want to consider automating the process in VFP with one of Mike's suggestions, or VFP automation of your existing procedure or even low-level operations (FOPEN(),FGET(),etc.).

Good Luck,
JRB-Bldr
 
Thanks.

Create /use existing table. Then Use command :-
APPEND FROM 'Filename.txt' TYPE delimited

Solved.

Note:
Comparison "Export/save as DBF file"
-Standard feature have in Excel 2003
-Microsoft removed the export/save as DBF option from Excel 2007.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top