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

import of .cls crashes vfp9 1

Status
Not open for further replies.

CJMK

Programmer
Jul 2, 2014
30
US

import from .xls crashed vfp
Tried appending from .csv, but yields extra rows by cutting off before end of record though why it should do this after a close paren is beyond me.
 
1. You can still change the title of your post by editing. .cls to .xls
2. Import of XLS files only works up to a certain version of Excel, so VFP can't import all xls. Its inability does not start with the change o the totally differrent XLSX format. If there are multiplle sheets in the XLS, you may succeed if you only keep the first one and save in a legacy format - at most Excel 97 (version 5), IIRC.
3. In CSV importing VFP does not care for quoted text values with multiple lines, i.e. it takes a line feed withing quotes as end of record, so VFP's csv import capabilities are limited, too.

Also, are you using the IMPORT comand or APPEND TYPE XLS, or are you using the import wizard?

There are alternatives. If all else fails, ironically it helps to convert this to XLSX and use ImportFromXlsx from Vilhelm-Ion Praisach:


Chriss
 
You need to give us more information.

How exactly does the import "crash VFP". Do you see an error message? Does the program freeze? How are you performing the import (APPEND FROM? IMPORT command? Import Wizard?). And are you doing it as part of an application or interactively in the development environment?

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Mike,
Thanks. Gets fatal error c0000005 message that refers to errorlog file that does not appear to exist where specified. (yes I have show hidden files on) screenshot attached. Click OK and immediate shutdown. If I just wait, freezes. file was downloaded as csv. So when that didn't work, I saved as xls old type (97-2003) to get where I am now.
append from yields "no sheet found"
Hence, trying import.
Now working from command window but Original attempt on csv is programmed as follows
CLOSE DATABASES
USE chaplist EXCLUSIVE

SET SAFETY OFF

ZAP

newfile = GETFILE("txt,csv","Go Database chapters Table")

APPEND FROM (newfile) TYPE delimited

SET SAFETY ON
 
Okay, you partly answered Mikes questions indirectly.

You do use VFP ourself to do this, so pointing out code and tools helps.
But is it a 1 time requirement or regular?

CSV import has limitations, as said.

Opening CSV and saving as (97-2003) format is not giving exactly the binary format VFP needs to append or import. Then you're better off with the import tools I pointed out after you use Excel to open the CSV and save as modern XLSX format (2007 or higher). The backward compatibillity of saving as old formats was - at least it seems so - only tested to work with the old Excel itself, not with VFP importing. That discrepancy was well known as it came up. And it came up ca. 2007, which was after VFP9 was released. Still before it was discontinued, but you see, there is no MS VFP10, so there also can't be import from that only partially compatible legacy XLS format. To create the real XLS binary format VFP needs I think you'd need Excel 97.

So go with the modern format, the problem to import that has been solved. And isn't that even better?

Chriss
 
Chris,
Sorry, I am a bit slow with thanksgiving and all.
I have tried importfromxlsx and it seems to bring the data over very nicely, but mostly in memo fields, so I am writing a little routine to map those over to appropriately typed regular fields. It requires positional consistency between the two files' fields, but that is a bearable burden.

For the case instant, this is a one time deal, but the same issue arises frequently with other tables, so for me it is a common issue any time I download a csv from ... which is fairly frequent for me. Until recently, no problems.

And yes, once I have my utility written, it will be easy to simply save as xlsx and go forth.

Thanks a bunch.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top