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

Import CSV with delimiter ';'

Status
Not open for further replies.

hosek

Programmer
Nov 10, 2001
3
CZ
I have problem with import CSV file. If delimiter is ',' all is OK. If delimiter is ';' it is wrong. I use code:

tFile='xxx.csv'
oExcel=createobject('excel.application')
oExcel.workbooks.opentext(tFile)
oExcel.visible=.t.
release oExcel

Thanks
 
That makes sense. The definition of a CVS file from the VFP Help file is:
Include CSV to import data from a comma separated value file. A CSV file has field names as the first line in the file; the field names are ignored when the file is imported.

Rick
 
Assuming a semi-colon delimited file with character fields indicated by a double quite:

Code:
APPEND FROM [MyTextFile.CSV] TYPE DELIMITED ;
WITH CHARACTER ; WITH "

Brian
 
If you want go directly to Excel, you can:

Code:
tFile='xxx.csv'

lcFile=FILETOSTR(tFile)
STRTOFILE(CHRTRAN(lcFile,";",","),"trans_"+tFile)

oExcel=createobject('excel.application')
oExcel.workbooks.opentext(FULLPATH("trans_"+tFile))
oExcel.visible=.t.
release oExcel

Warning: The semi-colon was probably used because data contains commas, you might want to remove all commas before changing the semi-colons to commas.

Brian
 
Thanks baltman,

you are right - data contains commas

27303;Folie rozmer 23,50 ; 3.500; 1; 352
27303;Folie BOPP 350,30 ; 0.709; 4; 352

Hosek
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top