Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Import from a csv file
Message
From
15/05/2003 22:28:59
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00788762
Message ID:
00789080
Views:
23
Hi SHerry:

Yes, you can import it in one hit, via a cursor that is created with fields to mimic the fields of the csv file. You then insert from the cursor into a table that you have set up to hold the data. Here is a copy of code I used to do this:

CREATE cursor 'roads_cr' ( ;
fld1 c(50), ;
fld2 c(30) , ;
fld3 c(30), ;
fld4 c(5), ;
fld5 i, ;
fld6 i, ;
fld7 i)

SELECT roads_cr
APPEND FROM ("f:\nzpost\postcode\csv_data\other_road.csv") TYPE csv

go top
SCAN all
INSERT INTO all_road (cStreet, cCity, cSuburb, cSide, iFrom, iTo, iPostcode, dCreated, dModified, cUser);
VALUES (roads_cr.fld1, roads_cr.fld2, roads_cr.fld3, roads_cr.fld4, roads_cr.fld5, roads_cr.fld6, roads_cr.fld7, DATETIME(), DATETIME(), "gnicholson")
endscan


Copy this into a .prg file and modify to suit

Godfrey
Godfrey Nicholson
Ofek Technologies Ltd
Auckland
New Zealand
Previous
Reply
Map
View

Click here to load this message in the networking platform