Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
APPEND FROM missing a column
Message
De
20/02/2017 18:46:54
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows Server 2012 R2
Network:
Windows Server 2012
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01648241
Message ID:
01648243
Vues:
43
>Hi All,
>I am importing a file and noticed that it sometimes mises a column. I have a cursor with 12 text columns and am appending in a csv file with various values. If I use
>
APPEND FROM &mFileName TYPE csv
>Then I miss the top row, which I need. So I've bene using this, but it gave a weird issue today. If there is any column, field, that does not have data at all then it is skipped, so field 9 becomes field 8. If even 1 field 9 has data then it is fine, but for me field 9 will be blank a lot and I rely on a calculation based on any values in field 8.
>
APPEND FROM &mFileName delimited with ,
>Any idea how to solve this?

With CSVs, one thing I've done in the past:

- Before importing, read in the file to a string variable using FILETOSTR()
- Copy the top row (column headers/names) to a separate variable etc. This is everything up to the first carriage return/line feed combination i.e. CHR( 13 ) + CHR( 10 ) . You can then parse that variable to get the column names

Then import normally using the CSV option.

Actually, thinking about it you can get the headers with FILETOSTR() either before or after the CSV import, the timing doesn't matter.
Regards. Al

"Violence is the last refuge of the incompetent." -- Isaac Asimov
"Never let your sense of morals prevent you from doing what is right." -- Isaac Asimov

Neither a despot, nor a doormat, be

Every app wants to be a database app when it grows up
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform