0

I've got a script that's scraping CSV files. Each day I get 36 individual CSV files, each with about 100 lines of data.

I want to load these into SQL Server 2008 each day. I've tried using Bulk Insert, but it doesn't like my CSV files very much, with inconsistent quotation marks.

I've just found out about BCP.exe, is that a good solution?

The CSV file looks like this (the top line is ignored)

24544,"1970-01-01 10:00:00","8056060 kWh"
24544,"2012-12-04 00:15:00",0.176
24544,"2012-12-04 00:30:00",0.163
24544,"2012-12-04 00:45:00",0.016
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
user1745767
  • 1,061
  • 2
  • 11
  • 16
  • 1
    " it doesn't like....inconsistent quotation marks." No one likes inconsistent quotation marks. Whatever the solution, you will have to scrub your data. – Steve Wellens Dec 16 '12 at 23:19

1 Answers1

0

create a table first then execute the query

BULK
INSERT CSVTest           -- the tableName
FROM 'c:\csvtest.txt'    -- file location
WITH  
(
    FIELDTERMINATOR = ',',
    ROWTERMINATOR = '\n'
)
GO
John Woo
  • 258,903
  • 69
  • 498
  • 492