2

The file content like this

'COGT','COGT','COGENT ORD'
'COG','COG','CABOT OIL & GAS ORD'
'COGZF','COGZF','COGSTATE ORD'
'COHG','COHG','CHEETAH OIL & GAS ORD'
'COHIQ','COHIQ','COHO ENERGY ORD'
'COHM','COHM','ALL AMERICAN GROUP ORD'
'COHN','COHN','COHEN ORD'
'COHR','COHR','COHERENT '

But i need to get it into a mysql database contain columns name,description you can also see first and second same so i want only one for name 3rd for description My espected output like

NAME   |      DESCRIPTION
cogt   |      cogt ord
cog    |      cabot oil

if you have any idea kindely share to me

user1433060
  • 31
  • 1
  • 8

1 Answers1

5

You can then import it into a MySQL table by running:

load data local infile 'input_file.csv' into table tblUniq fields terminated by ','
enclosed by '"'
lines terminated by '\n'
(NAME, DESCRIPTION)
AzizSM
  • 6,199
  • 4
  • 42
  • 53
  • Since the CSV has three columns while table has two, you need to specify the columns like this: `(NAME, @dummy, DESCRIPTION)` -- assigning a CSV column to an unused user variable means the column is sent to _the void_. You also need `IGNORE 1 LINES` to skip the header row. – Salman A Jun 11 '12 at 07:07
  • The solution given are for your initial question using MySQL however if you are looking for in C++. Then there already a answer in SO [http://stackoverflow.com/questions/415515/how-can-i-read-and-manipulate-csv-file-data-in-c](http://stackoverflow.com/questions/415515/how-can-i-read-and-manipulate-csv-file-data-in-c) to read file and you may put in `INSERT INTO` Statement to get it work. – AzizSM Jun 11 '12 at 07:15