Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Importing an Excel File
Message
De
03/10/2003 04:50:03
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
03/10/2003 00:06:08
Chris Hui
www.adv-plus.com
Kwun Tong, Hong Kong
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Divers
Thread ID:
00834086
Message ID:
00834685
Vues:
17
>Hi Cetin,
>
>Thanks for your suggestion.
>
>You said that it is not so good to import (or append) from a CSV. Why? Is there any hidden issue with it approach?
>
>I have tried to append a CSV to a cursor. it works fine basically. But I found one problem, which happen when the (excel) cell contains the double quote character ".
>
>For example,
>The value of the (excel) cell should be: 123"45
>After saved as a CSV, that value in the CSV becomes: "123""45"
>After appended to a dbf, it becomes: 123""45
>
>There is an additional double quote character in the dbf.... Do you know if there is any method to deal with this?
>
>And you mentioned about the automation. Please let me know if I am right on this:
>"The automation is just used to save the excel file as a dbf. I can get exactly the same dbf by doing it manually in Excel." Am I correct?
>
>(Just wanna share with everyone. Not intented to challenge anyone...) If I am right, maybe this approach might not work so well for me. My xls files contains some non-english (chinese) characters. I found that when I saved the xls as dbf, some characters are missing in the dbf. Even thought I have widen all the (excel) cells width so that all data are visible.... Did you encounter similar problem before?
>
>Regards,
>Chris Hui

Chris,
IMHO CSV is not a good idea because with the first header line every column is treated as character and you might need conversion thereafter.
" is not a problem, you might process the file with strtran before import. ie:

Assuming % doesn't exist in your data
StrToFile(ChrTran(ChrTran(;
  StrTran(FileToStr('myCSV.csv'),'""','%'),'"',"'"),'%','"'), 'mycsv.csv')

ALines(arrFile,FileToStr('myCSV.csv'))
lcStruc = Strtran(arrFile[1],',',' c(254),')+ ' c(254)'
Create Cursor myCursor (&lcStruc)
Append From 'myCSV.csv' type delimited with "'"
What you do is changing dblquotes for field delimiters to single and infield double dblquotes to dblqutoes.

I don't know how to deal with double byte characters. Saving as dbaseIII is same as saving fox2x type.

Maybe ODBC or OLEDB connection to excel might yield better results (I doubt).
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform