Import data from a csv file

campbme
campbme used Ask the Experts™
on
I need to import data from a csv file to a Vfp table called Laundry.  In the csv file, there are three data fields(Date, Total Weight, Description) to import into the vfp table.  I have the csv file attached below.  What code can I use to import the csv data?

Laundry table-fields                                  csv file-fields

Date----------------------------------------------05/01/2014
blktdescript-------------------------------------Blankets
blktamtin----------------------------------------Total Weight
shtpdescript------------------------------------Flat Sheets
shtpamtin---------------------------------------Total Weight
shtbtdescript------------------------------------Fit Sheets
shtbtamtin--------------------------------------Total Weight
sprddescript------------------------------------Spreads
sprdamtin---------------------------------------Total Weight
Btdescript---------------------------------------Bath Towels
Btamtin------------------------------------------Total Weight
Bstdescript-------------------------------------Bea Shop Towels
Bstamtin----------------------------------------Total Weight
Pcdescript--------------------------------------Pillow Cases
pcamtin-----------------------------------------Total Weight
Wcdescript-------------------------------------Wash Cloths
wcamtin----------------------------------------Total Weight
Oth21descript---------------------------------Personal Garment
oth21amtin------------------------------------Total Weight
1-2014-5-1-8-1.csv
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Rob HensonFinance Analyst

Commented:
The csv file uploaded doesn't really show a lot. A larger data set will be required.

Thanks
Rob H
you dont need "code"
why not just use the SQl server management studio and import the CSV file mapped to the appropriate tables :)

Here is a step by step guide with pictures to show you how to accompligh this is SSMS

http://www.rodolforodarte.com/2010/03/importing-data-into-sql-server-using-the-import-export-wizard/
Top Expert 2014

Commented:
1. the file you uploaded is not a well-formed CSV format.  There are lines prior to the CSV (row/col) data.
5/1/2014,8:01:01,
Account Number:,1,
,,

Open in new window

2. The CSV data does not match expected values.  The Total Weight field contains all zero values.
three data fields(Date, Total Weight, Description)

ITEM #:,TOTAL WEIGHT,DESCRIPTION
1,0,BLANKETS
2,0,FLAT SHEETS
3,0,FIT SHEETS
4,0,SPREADS
5,0, BATH TOWELS
6,0,BEA SHOP TOWELS
7,0,PILLOW  CASES
8,0,WASH CLOTHS
9,0,PERSONAL GARMENT

Open in new window

Qlemo"Batchelor", Developer and EE Topic Advisor
Top Expert 2015

Commented:
And it is more complex than a simple import. You want to add the row values into different columns, that is create a pivot table.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial